ThisApplication.java 3.3 KB
Newer Older
R
roo00 已提交
1 2
package com.x.message.assemble.communicate;

NoSubject's avatar
NoSubject 已提交
3
import com.x.base.core.project.message.MessageConnector;
R
roo00 已提交
4 5
import org.apache.commons.lang3.BooleanUtils;

R
roo00 已提交
6
import com.x.base.core.project.Context;
Z
zhourui 已提交
7
import com.x.base.core.project.cache.CacheManager;
R
roo00 已提交
8
import com.x.base.core.project.config.Config;
R
roo00 已提交
9 10
import com.x.base.core.project.logger.LoggerFactory;
import com.x.message.assemble.communicate.schedule.Clean;
hlwwx's avatar
hlwwx 已提交
11 12
import com.x.message.assemble.communicate.schedule.TriggerMq;
import com.x.message.core.entity.Message;
R
roo00 已提交
13 14 15 16 17

public class ThisApplication {

	protected static Context context;

R
roo00 已提交
18
	public static WsConsumeQueue wsConsumeQueue = new WsConsumeQueue();
R
roo00 已提交
19 20 21 22 23 24 25 26 27 28 29

	public static PmsConsumeQueue pmsConsumeQueue = new PmsConsumeQueue();

	public static CalendarConsumeQueue calendarConsumeQueue = new CalendarConsumeQueue();

	public static QiyeweixinConsumeQueue qiyeweixinConsumeQueue = new QiyeweixinConsumeQueue();

	public static ZhengwuDingdingConsumeQueue zhengwuDingdingConsumeQueue = new ZhengwuDingdingConsumeQueue();

	public static DingdingConsumeQueue dingdingConsumeQueue = new DingdingConsumeQueue();

F
fancy 已提交
30 31
	public static WeLinkConsumeQueue weLinkConsumeQueue = new WeLinkConsumeQueue();

R
update  
roo00 已提交
32
	public static PmsInnerConsumeQueue pmsInnerConsumeQueue = new PmsInnerConsumeQueue();
Z
zhourui 已提交
33

hlwwx's avatar
hlwwx 已提交
34
	public static MQConsumeQueue mqConsumeQueue = new MQConsumeQueue();
R
update  
roo00 已提交
35

R
roo00 已提交
36 37 38 39 40 41
	public static Context context() {
		return context;
	}

	public static void init() {
		try {
Z
zhourui 已提交
42
			CacheManager.init(context.clazz().getSimpleName());
R
roo00 已提交
43
			LoggerFactory.setLevel(Config.logLevel().x_message_assemble_communicate());
R
update  
roo00 已提交
44 45 46 47 48 49 50 51 52 53 54 55
			if (Config.communicate().wsEnable()) {
				wsConsumeQueue.start();
			}
			if (Config.communicate().pmsEnable()) {
				pmsConsumeQueue.start();
			}
			if (Config.communicate().calendarEnable()) {
				calendarConsumeQueue.start();
			}
			if (BooleanUtils.isTrue(Config.communicate().clean().getEnable())) {
				context().schedule(Clean.class, Config.communicate().clean().getCron());
			}
R
roo00 已提交
56 57 58 59 60 61 62 63
			if (BooleanUtils.isTrue(Config.qiyeweixin().getEnable())
					&& BooleanUtils.isTrue(Config.qiyeweixin().getMessageEnable())) {
				qiyeweixinConsumeQueue.start();
			}
			if (BooleanUtils.isTrue(Config.zhengwuDingding().getEnable())
					&& BooleanUtils.isTrue(Config.zhengwuDingding().getMessageEnable())) {
				zhengwuDingdingConsumeQueue.start();
			}
R
update  
roo00 已提交
64
			if (Config.dingding().getEnable() && Config.dingding().getMessageEnable()) {
R
roo00 已提交
65 66
				dingdingConsumeQueue.start();
			}
R
update  
roo00 已提交
67 68
			if (BooleanUtils.isTrue(Config.pushConfig().getEnable())) {
				pmsInnerConsumeQueue.start();
R
roo00 已提交
69
			}
F
fancy 已提交
70 71 72
			if (Config.weLink().getEnable() && Config.weLink().getMessageEnable()) {
				weLinkConsumeQueue.start();
			}
Z
zhourui 已提交
73

hlwwx's avatar
hlwwx 已提交
74 75 76
			if (Config.mq().getEnable()) {
				mqConsumeQueue.start();
			}
Z
zhourui 已提交
77

NoSubject's avatar
NoSubject 已提交
78
			MessageConnector.start(context());
Z
zhourui 已提交
79

hlwwx's avatar
hlwwx 已提交
80
			if (BooleanUtils.isTrue(Config.communicate().cronMq().getEnable())) {
Z
zhourui 已提交
81
				context().schedule(TriggerMq.class, Config.communicate().cronMq().getCron());
hlwwx's avatar
hlwwx 已提交
82
			}
Z
zhourui 已提交
83

R
roo00 已提交
84 85 86 87 88 89 90
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void destroy() {
		try {
Z
zhourui 已提交
91
			CacheManager.shutdown();
R
roo00 已提交
92
			wsConsumeQueue.stop();
R
roo00 已提交
93 94
			pmsConsumeQueue.stop();
			calendarConsumeQueue.stop();
R
update  
roo00 已提交
95 96 97 98
			qiyeweixinConsumeQueue.stop();
			zhengwuDingdingConsumeQueue.stop();
			dingdingConsumeQueue.stop();
			pmsInnerConsumeQueue.stop();
F
fancy 已提交
99
			weLinkConsumeQueue.stop();
NoSubject's avatar
NoSubject 已提交
100
			MessageConnector.stop();
R
roo00 已提交
101 102 103 104 105
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}