package com.ssj.service.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import com.ssj.bean.sys.fx.domain.Device;
import com.ssj.framework.core.rabbitmq.TopicRabbitConfig;
import com.ssj.service.sys.fx.service.DeviceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TopicFXSSJConsumer {
	
	  private static Logger logger = LoggerFactory.getLogger(TopicFXSSJConsumer.class);
		
	  @Autowired
	  private DeviceService deviceService;
	  
	  @RabbitListener(queues = {TopicRabbitConfig.topic_fx_ssj})
	  @RabbitHandler
	  public void handleMessage(Message message){
	  	  try {
			  Device device=JSONObject.parseObject(message.getBody(),Device.class);
			  deviceService.matchDeviceByMQ(device);
		  } catch (Exception e){
	  	  	  logger.error("消费队列消费异常" + e);
		  }
	  }
}


