From 06bbe3130549b941be8c46564cf4b1e4c85edacb Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 03 Jun 2021 17:05:05 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 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 index cd29a9e..e52c731 100644 --- a/src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java +++ b/src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java @@ -2,6 +2,7 @@ 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; @@ -15,6 +16,8 @@ import org.springframework.stereotype.Component; import java.util.Date; +import java.util.HashMap; +import java.util.Map; @Slf4j @Component @@ -32,23 +35,22 @@ rabbitTemplate.setConfirmCallback(this); } - public void sendMarketBussinessMsg(String content) { + public void sendMarketBussinessMsg(Long entrustOrderId, Integer status) { log.info("发送市商消息"); CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); - rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTINGKEY_MARKET_BUSSINESS, content, correlationData); + 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()); - amqpTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_DELAY, RabbitMqConfig.ROUTING_KEY_DELAY, content, new MessagePostProcessor() { - @Override - public Message postProcessMessage(Message message) throws AmqpException { - //设置消息持久化 - message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT); - message.getMessageProperties().setHeader("x-delay", 6000);//设置延时时间 - return message; - } + rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_DELAY, RabbitMqConfig.ROUTING_KEY_DELAY, content, message -> { + message.getMessageProperties().setExpiration(6000 + ""); + return message; }); } -- Gitblit v1.9.1