ThisApplication.java 2.6 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;
R
roo00 已提交
7
import com.x.base.core.project.config.Config;
R
roo00 已提交
8 9
import com.x.base.core.project.logger.LoggerFactory;
import com.x.message.assemble.communicate.schedule.Clean;
R
roo00 已提交
10 11 12 13 14

public class ThisApplication {

	protected static Context context;

R
roo00 已提交
15
	public static WsConsumeQueue wsConsumeQueue = new WsConsumeQueue();
R
roo00 已提交
16 17 18 19 20 21 22 23 24 25 26

	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();

R
update  
roo00 已提交
27 28
	public static PmsInnerConsumeQueue pmsInnerConsumeQueue = new PmsInnerConsumeQueue();

R
roo00 已提交
29 30 31 32 33 34
	public static Context context() {
		return context;
	}

	public static void init() {
		try {
R
roo00 已提交
35
			LoggerFactory.setLevel(Config.logLevel().x_message_assemble_communicate());
R
update  
roo00 已提交
36 37 38 39 40 41 42 43 44 45 46 47
			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 已提交
48 49 50 51 52 53 54 55
			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 已提交
56
			if (Config.dingding().getEnable() && Config.dingding().getMessageEnable()) {
R
roo00 已提交
57 58
				dingdingConsumeQueue.start();
			}
R
update  
roo00 已提交
59 60
			if (BooleanUtils.isTrue(Config.pushConfig().getEnable())) {
				pmsInnerConsumeQueue.start();
R
roo00 已提交
61
			}
NoSubject's avatar
NoSubject 已提交
62 63 64

			MessageConnector.start(context());

R
roo00 已提交
65 66 67 68 69 70 71
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void destroy() {
		try {
R
roo00 已提交
72
			wsConsumeQueue.stop();
R
roo00 已提交
73 74
			pmsConsumeQueue.stop();
			calendarConsumeQueue.stop();
R
update  
roo00 已提交
75 76 77 78
			qiyeweixinConsumeQueue.stop();
			zhengwuDingdingConsumeQueue.stop();
			dingdingConsumeQueue.stop();
			pmsInnerConsumeQueue.stop();
NoSubject's avatar
NoSubject 已提交
79
			MessageConnector.stop();
R
roo00 已提交
80 81 82 83 84
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}