|
@@ -2,12 +2,14 @@ package com.huaxu.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.huaxu.entity.Message;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.core.AmqpTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class MessageSendUtil {
|
|
|
@Autowired
|
|
|
private AmqpTemplate rabbitTemplate;
|
|
@@ -16,6 +18,7 @@ public class MessageSendUtil {
|
|
|
@Value("${dispath.routing.key}")
|
|
|
private String dispathRoutingKey;
|
|
|
public void send(Message message){
|
|
|
+ log.debug("消息发送 exchange={} routingkey={} 用户id={}",receiveExchangeName,dispathRoutingKey,message.getUserId());
|
|
|
rabbitTemplate.convertAndSend(receiveExchangeName,dispathRoutingKey, JSONObject.toJSONString(message));
|
|
|
}
|
|
|
}
|