package com.webchat;

import com.webchat.common.util.SpringContextUtil;
import com.webchat.service.listener.RedisChatMessageListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 技术讲解学习社区：https://www.coderutil.com/star/28
 * 加社区学习线下交流群：https://www.coderutil.com/star/qa/1858
 */
@ServletComponentScan
@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.webchat.repository")
@EnableAsync
public class WebChatApplication {

	public static void main(String[] args) {

		SpringApplication.run(WebChatApplication.class, args);

		StringBuilder sb = new StringBuilder();
		sb.append("=======================================================================");
		sb.append("\n");
		sb.append("========================== SERVER START SUCCESS！！ ===================");
		sb.append("\n");
		sb.append("=======================================================================");
		System.out.println(sb);
		RedisChatMessageListener chatMessageListener = SpringContextUtil.getBean(RedisChatMessageListener.class);
		new Thread(() -> chatMessageListener.consumeMessageQueue()).start();
	}
}
