From 6c2e9ba62c418185361179e7014862c481f34e17 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 09 Mar 2022 14:22:09 +0800 Subject: [PATCH] conflect merge --- src/main/java/com/xcong/excoin/rabbit/producer/ChatProducer.java | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/xcong/excoin/rabbit/producer/ChatProducer.java b/src/main/java/com/xcong/excoin/rabbit/producer/ChatProducer.java new file mode 100644 index 0000000..d939432 --- /dev/null +++ b/src/main/java/com/xcong/excoin/rabbit/producer/ChatProducer.java @@ -0,0 +1,33 @@ +package com.xcong.excoin.rabbit.producer; + + +import com.alibaba.fastjson.JSONObject; +import com.xcong.excoin.configurations.RabbitMqConfig; +import com.xcong.excoin.netty.bean.ChatRequest; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Slf4j +@Component +public class ChatProducer implements RabbitTemplate.ConfirmCallback { + + @Autowired + private RabbitTemplate rabbitTemplate; + + public void sendMsgHistory(ChatRequest chatRequest) { + CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); + log.info("消息持久化消息: {}, {}", chatRequest, correlationData.getId()); + String str = JSONObject.toJSONString(chatRequest); + rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTING_KEY_MSG_HISTORY, str, correlationData); + } + + @Override + public void confirm(CorrelationData correlationData, boolean b, String s) { + + } +} -- Gitblit v1.9.1