|
@@ -1,16 +1,20 @@
|
|
|
package com.fdkankan.rabbitmq.util;
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.fdkankan.rabbitmq.config.ModelingQueueConfig;
|
|
|
import com.rabbitmq.client.AMQP;
|
|
|
import com.rabbitmq.client.AMQP.Queue.DeclareOk;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
-import java.util.UUID;
|
|
|
+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;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* TODO
|
|
@@ -22,6 +26,8 @@ import org.springframework.stereotype.Component;
|
|
|
@Component
|
|
|
public class RabbitMqProducer {
|
|
|
|
|
|
+ private Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
+
|
|
|
@Autowired
|
|
|
ModelingQueueConfig modelingQueueConfig;
|
|
|
|
|
@@ -32,6 +38,7 @@ public class RabbitMqProducer {
|
|
|
* 工作队列模式发送
|
|
|
*/
|
|
|
public void sendByWorkQueue(String queue, Object content){
|
|
|
+ log.info("开始发送Mq消息,消息内容:{}", new JSONObject(content).toString());
|
|
|
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
|
|
rabbitTemplate.convertAndSend(queue, content, correlationId);
|
|
|
}
|