| | |
| | | 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.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | * @DATE: 2023/8/3 15:54 |
| | | */ |
| | | @Component |
| | | @AllArgsConstructor |
| | | public class MyRabbitReceiver { |
| | | private final IAlarmGetService alarmGetService; |
| | | |
| | | @RabbitListener(queues = "alarm") |
| | | public void processMessage(Message message) { |
| | | |
| | | AlarmGet alarmGet = JSONObject.parseObject(new String(message.getBody()), AlarmGet.class); |
| | | alarmGetService.save(alarmGet); |
| | | |
| | | System.out.println("收到消息"+new String(message.getBody())); |
| | | } |
| | | |