package cn.amq.business;

import java.util.List;

import org.apache.log4j.Logger;

import cn.amq.basis.AmqBasisEvent;
import cn.amq.basis.AmqConst;
import cn.amq.basis.AmqSubscribleBasisJob;
import cn.base.bean.BeanHelper;

import com.jtiny.utility.JtinyEvent;
/**
 * amq分派工作
 * @author ThinkPad
 *
 */
public class AmqSubscribleJob extends AmqSubscribleBasisJob{
	static Logger logger = Logger.getLogger(AmqSubscribleJob.class);
	
	public AmqSubscribleJob(String url,List<String> subscribleSubjectList){
		super(url,subscribleSubjectList);
		JtinyEvent eventTimer=new JtinyEvent(AmqConst.AMQ_SETUP_INIT_EVENT,0,0,null,null,null);
		this.registerTimer(eventTimer, 5000);
	}
	
	public void doSubscirbleJob(AmqBasisEvent amqBasisMsg) {
		//统计处理多少个subscrible消息
		String msgType=amqBasisMsg.getMsgType();
		if(msgType.equalsIgnoreCase(AmqConst.AMQ_MSG_safetyHatAlarm)){
			//接受安全帽告警信息
			BeanHelper.getAmqSafetyHatAlarmService().doSafetyHatAlarmAction(amqBasisMsg);
		}else if(msgType.equalsIgnoreCase(AmqConst.AMQ_MSG_videoTaskAlarm)){
			logger.info("----------------------------接收巡检任务信息");
			BeanHelper.getAmqVideoTaskAlarmService().doVideoTaskAlarmAction(amqBasisMsg);
		}else{
			logger.error("AmqSubscribleDispatchJob Received Unknow Message,Message Type="+msgType);
		}
	}
}