This commit is contained in:
张良(004796)
2024-01-12 17:50:50 +08:00
parent 728192d4f0
commit 28623f17d1
28 changed files with 746 additions and 110 deletions

View File

@@ -1,5 +1,7 @@
package com.ruoyi.cai.mq;
import com.alibaba.fastjson.JSON;
import com.ruoyi.cai.mq.consumer.AmqpConsumer;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -22,4 +24,17 @@ public class AmqpProducer {
return messagePostProcessor;
});
}
public void sendCommonDelayMq(Integer type,Long roomId,Integer timeout){
CommonDelayDto dto = new CommonDelayDto();
dto.setType(type);
dto.setRoomId(roomId);
rabbitTemplate.convertAndSend(CheckTimeOutMqConfig.EXCHANGE_NAME,
CheckTimeOutMqConfig.ROUTING_KEY,
JSON.toJSONString(dto),
messagePostProcessor -> {
messagePostProcessor.getMessageProperties().setDelay(timeout*1000); // 设置延迟时间,单位毫秒
return messagePostProcessor;
});
}
}