Helius
2021-05-26 5575818556096be1dadaf5ff356b5db4c832aaa2
src/main/java/com/xcong/excoin/rabbit/producer/OtcProducter.java
@@ -4,6 +4,11 @@
import cn.hutool.core.util.IdUtil;
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;
@@ -19,6 +24,9 @@
    private RabbitTemplate rabbitTemplate;
    @Autowired
    private AmqpTemplate amqpTemplate;
    @Autowired
    public OtcProducter(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
        rabbitTemplate.setConfirmCallback(this);
@@ -32,8 +40,9 @@
    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(1000 * 60 + "");
            message.getMessageProperties().setExpiration(6000 + "");
            return message;
        });
    }