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