| | |
| | | |
| | | |
| | | 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.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | 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; |
| | | }); |
| | | } |
| | | |
| | | 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) { |
| | | |