| | |
| | | package cn.gistack.nky.rabbitmq; |
| | | |
| | | import cn.gistack.nky.entity.AlarmGet; |
| | | import cn.gistack.nky.service.IAlarmGetService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | |
| | | /** |
| | | * @PROJECT_NAME: skjcmanager |
| | | * @DESCRIPTION: 接收南科院消息队列 |
| | | * @USER: aix |
| | | * @DATE: 2023/8/3 15:54 |
| | | */ |
| | | @Component |
| | | @AllArgsConstructor |
| | | public class MyRabbitReceiver { |
| | | private final IAlarmGetService alarmGetService; |
| | | |
| | | @RabbitListener(queues = "alarm") |
| | | public void processMessage(Message message) { |
| | | System.out.println("收到消息"+new String(message.getBody())); |
| | | AlarmGet alarmGet = JSONObject.parseObject(new String(message.getBody()), AlarmGet.class); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String format = sdf.format(DateUtil.now()); |
| | | alarmGet.setCreateTime(format); |
| | | alarmGetService.save(alarmGet); |
| | | } |
| | | |
| | | } |
| | | //package cn.gistack.nky.rabbitmq; |
| | | // |
| | | //import cn.gistack.nky.entity.AlarmGet; |
| | | //import cn.gistack.nky.service.IAlarmGetService; |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import lombok.AllArgsConstructor; |
| | | //import org.springblade.core.tool.utils.DateUtil; |
| | | //import org.springframework.amqp.core.Message; |
| | | //import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import java.text.SimpleDateFormat; |
| | | // |
| | | ///** |
| | | // * @PROJECT_NAME: skjcmanager |
| | | // * @DESCRIPTION: 接收南科院消息队列 |
| | | // * @USER: aix |
| | | // * @DATE: 2023/8/3 15:54 |
| | | // */ |
| | | //@Component |
| | | //@AllArgsConstructor |
| | | //public class MyRabbitReceiver { |
| | | // private final IAlarmGetService alarmGetService; |
| | | // |
| | | // @RabbitListener(queues = "alarm") |
| | | // public void processMessage(Message message) { |
| | | // System.out.println("收到消息"+new String(message.getBody())); |
| | | // AlarmGet alarmGet = JSONObject.parseObject(new String(message.getBody()), AlarmGet.class); |
| | | // |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String format = sdf.format(DateUtil.now()); |
| | | // alarmGet.setCreateTime(format); |
| | | // alarmGetService.save(alarmGet); |
| | | // } |
| | | // |
| | | //} |