|
|
@ -1,8 +1,11 @@
|
|
|
|
package com.java3y.austin.support.mq.rabbit;
|
|
|
|
package com.java3y.austin.support.mq.rabbit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
|
|
|
import com.google.common.base.Throwables;
|
|
|
|
import com.java3y.austin.support.constans.MessageQueuePipeline;
|
|
|
|
import com.java3y.austin.support.constans.MessageQueuePipeline;
|
|
|
|
import com.java3y.austin.support.mq.SendMqService;
|
|
|
|
import com.java3y.austin.support.mq.SendMqService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
|
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;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@ -40,10 +43,20 @@ public class RabbitSendMqServiceImpl implements SendMqService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void send(String topic, String jsonValue, String tagId) {
|
|
|
|
public void send(String topic, String jsonValue, String tagId) {
|
|
|
|
|
|
|
|
CorrelationData correlationData = new CorrelationData(IdUtil.getSnowflake().nextIdStr());
|
|
|
|
|
|
|
|
correlationData.getFuture().addCallback(result -> {
|
|
|
|
|
|
|
|
if (result.isAck()) {
|
|
|
|
|
|
|
|
log.info("消息成功投递到交换机,消息ID:{}", correlationData.getId());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
log.error("消息投递到交换机失败,消息ID:{}", correlationData.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, ex -> {
|
|
|
|
|
|
|
|
log.error("消息处理异常,{}", Throwables.getStackTraceAsString(ex));
|
|
|
|
|
|
|
|
});
|
|
|
|
if (topic.equals(sendMessageTopic)){
|
|
|
|
if (topic.equals(sendMessageTopic)){
|
|
|
|
rabbitTemplate.convertAndSend(exchangeName, sendRoutingKey, jsonValue);
|
|
|
|
rabbitTemplate.convertAndSend(exchangeName, sendRoutingKey, jsonValue, correlationData);
|
|
|
|
}else if (topic.equals(austinRecall)){
|
|
|
|
}else if (topic.equals(austinRecall)){
|
|
|
|
rabbitTemplate.convertAndSend(exchangeName, recallRoutingKey, jsonValue);
|
|
|
|
rabbitTemplate.convertAndSend(exchangeName, recallRoutingKey, jsonValue, correlationData);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
log.error("RabbitSendMqServiceImpl send topic error! topic:{}", topic);
|
|
|
|
log.error("RabbitSendMqServiceImpl send topic error! topic:{}", topic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|