package com.iamberry.wechat.handles.mq;

import java.util.List;

import org.springframework.stereotype.Service;

import com.iamberry.wechat.core.entity.mq.MQMessage;
import com.iamberry.wechat.face.mq.MQSerivce;
import com.iamberry.zk.SpringContextHolder;

/**
 * @company	深圳爱贝源科技有限公司
 * @website www.iamberry.com
 * @author 	献
 * @tel		18271840547
 * @date	2016年9月21日
 * @explain	service代理
 */
@Service
public class MQServiceProxy implements MQSerivce {

	@Override
	public List<MQMessage> selectWaitHandlerMessage() {
		// TODO Auto-generated method stub
		MQSerivce mqSerivce = SpringContextHolder.getBean("MQSerivceImpl");
		return mqSerivce.selectWaitHandlerMessage();
	}

	@Override
	public Integer updateBatchMessage(List<MQMessage> messages) {
		// TODO Auto-generated method stub
		MQSerivce mqSerivce = SpringContextHolder.getBean("MQSerivceImpl");
		return mqSerivce.updateBatchMessage(messages);
	}

	@Override
	public boolean insertMQMessage(MQMessage message) {
		// TODO Auto-generated method stub
		boolean flag = MQTimer.messageStaticQueue.offer(message);;
		if (!flag) {
			MQSerivce mqSerivce = SpringContextHolder.getBean("MQSerivceImpl");
			return mqSerivce.insertMQMessage(message);
		}
		return false;
	}

	@Override
	public boolean updateMessageOne(MQMessage message) {
		// TODO Auto-generated method stub
		MQSerivce mqSerivce = SpringContextHolder.getBean("MQSerivceImpl");
		return mqSerivce.updateMessageOne(message);
	}

	@Override
	public Integer insertOneMQMessageContainError(MQMessage message) {
		// TODO Auto-generated method stub
		MQSerivce mqSerivce = SpringContextHolder.getBean("MQSerivceImpl");
		return mqSerivce.insertOneMQMessageContainError(message);
	}

}
