package com.iamberry.wechat.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.iamberry.app.tool.log.RatFWLogger;
import com.iamberry.wechat.face.mq.MQSerivce;
import com.iamberry.wechat.handles.mq.MQTimer;
import com.iamberry.zk.SpringContextHolder;

/**
 * @company	深圳爱贝源科技有限公司
 * @website www.iamberry.com
 * @author 	献
 * @tel		18271840547
 * @date	2016年10月18日
 * @explain	通过监听器启动定时器，定时器内永久循环
 */
public class MessageQueueListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {
	}

	public void contextInitialized(ServletContextEvent arg0) {
		MQSerivce mQSerivce = SpringContextHolder.getBean("MQServiceProxy");
	    RatFWLogger ratFWLogger = SpringContextHolder.getBean("logger");
	    ratFWLogger.info("订阅队列消息 监听器 启动....");
	    new Timer().schedule(new MQTimer(mQSerivce, ratFWLogger), 5000);
	}
}
