|
@@ -7,6 +7,7 @@ import com.rabbitmq.client.AMQP.Queue.DeclareOk;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
import org.springframework.amqp.rabbit.core.ChannelCallback;
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -37,11 +38,12 @@ public class RabbitMqProducer {
|
|
|
* 工作队列模式发送
|
|
|
*/
|
|
|
public void sendByWorkQueue(String queue, Object content){
|
|
|
- log.info("开始发送Mq消息,消息队列:{},消息内容:{}",queue, new JSONObject(content).toString());
|
|
|
+ String messageId = UUID.randomUUID().toString();
|
|
|
+ log.info("开始发送Mq消息,messageId:{},消息队列:{},消息内容:{}",messageId, queue, new JSONObject(content).toString());
|
|
|
rabbitTemplate.convertAndSend(queue, content, message -> {
|
|
|
- message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
|
+ message.getMessageProperties().setMessageId(messageId);
|
|
|
return message;
|
|
|
- });
|
|
|
+ }, new CorrelationData(messageId));
|
|
|
}
|
|
|
|
|
|
/**
|