| | |
| | | package com.ks.push; |
| | | |
| | | import com.ks.push.consumer.mq.PushTaskConsumer; |
| | | import com.ks.push.pojo.DO.PushPlatform; |
| | | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.builder.SpringApplicationBuilder; |
| | | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.context.event.ContextRefreshedEvent; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | | import org.yeshi.utils.mq.JobThreadExecutorServiceImpl; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @SpringBootApplication |
| | | @EnableTransactionManagement |
| | |
| | | @EnableDubbo(scanBasePackages = "com.ks.push.service.remote") |
| | | public class PushApplication implements ApplicationListener<ContextRefreshedEvent> { |
| | | private final static Logger logger = LoggerFactory.getLogger(PushApplication.class); |
| | | |
| | | @Resource |
| | | private PushTaskConsumer pushTaskConsumer; |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(PushApplication.class, args); |
| | |
| | | @Override |
| | | public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { |
| | | logger.info("容器加载完毕"); |
| | | initMQMsgConsumer(); |
| | | } |
| | | |
| | | private void initMQMsgConsumer() { |
| | | final int THREAD_NUM = 3; |
| | | for (PushPlatform pushPlatform : PushPlatform.values()) { |
| | | //创建三条队列处理 |
| | | for (int i = 0; i < THREAD_NUM; i++) { |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushTaskConsumer.consumeMsg(pushPlatform); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |