增加业务1
parent
d6b59915be
commit
4a5d2a5746
|
@ -1,11 +1,13 @@
|
|||
package com.dragon.car.service.rabbit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.dragon.car.service.service.FaultService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,10 +23,14 @@ import java.util.HashMap;
|
|||
@Log4j2
|
||||
public class ListenFaultCode {
|
||||
|
||||
@Autowired
|
||||
private FaultService faultService;
|
||||
@RabbitListener(queuesToDeclare = {@Queue(value = "fault_Dqueue")})
|
||||
public void consumerSubscribe(String mesg, Message message, Channel channel) {
|
||||
log.info("收到消息【{}】", JSONObject.parseObject(mesg, HashMap.class));
|
||||
HashMap hashMap = JSONObject.parseObject(mesg, HashMap.class);
|
||||
log.info("收到消息【{}】", hashMap);
|
||||
try {
|
||||
faultService.insertFaultRecord(hashMap);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
Loading…
Reference in New Issue