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/OtcProducter.java | 68 ++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java b/src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java new file mode 100644 index 0000000..cbfb6da --- /dev/null +++ b/src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java @@ -0,0 +1,68 @@ +package com.xcong.excoin.rabbit.producer; + + +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSONObject; +import com.xcong.excoin.configurations.RabbitMqConfig; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.AmqpException; +import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageDeliveryMode; +import org.springframework.amqp.core.MessagePostProcessor; +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.Date; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Component +public class OtcProducter implements RabbitTemplate.ConfirmCallback { + + @Autowired + private RabbitTemplate rabbitTemplate; + + @Autowired + private AmqpTemplate amqpTemplate; + + @Autowired + public OtcProducter(RabbitTemplate rabbitTemplate) { + this.rabbitTemplate = rabbitTemplate; + rabbitTemplate.setConfirmCallback(this); + } + + public void sendMarketBussinessMsg(Long entrustOrderId, Integer status) { + log.info("发送市商消息"); + CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); + Map<String, Object> map = new HashMap<>(); + map.put("entrustOrderId", entrustOrderId); + map.put("status", status); + String s = JSONObject.toJSONString(map); + rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTINGKEY_MARKET_BUSSINESS, s, correlationData); + } +// +// public void sendDelayOrderMsg(String content) { +// log.info("-----{}", new Date()); +// CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); +// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_DELAY, RabbitMqConfig.ROUTING_KEY_DELAY, content, message -> { +// message.getMessageProperties().setExpiration(6000 + ""); +// return message; +// }); +// } + + public void sendOrderReturn(String content) { + log.info("发送返佣消息"); + CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); + rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTING_ORDER_RETURN, content, correlationData); + + } + + @Override + public void confirm(CorrelationData correlationData, boolean b, String s) { + + } +} -- Gitblit v1.9.1