123
This commit is contained in:
@@ -25,6 +25,16 @@ public class AmqpProducer {
|
||||
});
|
||||
}
|
||||
|
||||
public void sendCommonDelayMq(CommonDelayDto dto,Integer timeout){
|
||||
rabbitTemplate.convertAndSend(CommonDelayMqConfig.EXCHANGE_NAME,
|
||||
CommonDelayMqConfig.ROUTING_KEY,
|
||||
JSON.toJSONString(dto),
|
||||
messagePostProcessor -> {
|
||||
messagePostProcessor.getMessageProperties().setDelay(timeout*1000); // 设置延迟时间,单位毫秒
|
||||
return messagePostProcessor;
|
||||
});
|
||||
}
|
||||
|
||||
public void sendCommonDelayMq(Integer type,Long roomId,Integer timeout){
|
||||
CommonDelayDto dto = new CommonDelayDto();
|
||||
dto.setType(type);
|
||||
|
||||
@@ -4,6 +4,8 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommonDelayDto {
|
||||
// 1- 房间检测 2-黑名单检测
|
||||
private Integer type;
|
||||
private Long roomId;
|
||||
private Long forbidId;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.mq.consumer;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.cai.manager.UserForbidManager;
|
||||
import com.ruoyi.cai.mq.AmqpProducer;
|
||||
import com.ruoyi.cai.mq.CommonDelayDto;
|
||||
import com.ruoyi.cai.mq.CommonDelayMqConfig;
|
||||
@@ -16,7 +17,7 @@ public class CommonDelayMqConsumer {
|
||||
@Autowired
|
||||
private CheckTimeOutJob checkTimeOutJob;
|
||||
@Autowired
|
||||
private AmqpProducer amqpProducer;
|
||||
private UserForbidManager userForbidManager;
|
||||
|
||||
@RabbitListener(queues = CommonDelayMqConfig.QUEUE_NAME
|
||||
,containerFactory = "customContainerFactory")
|
||||
@@ -27,6 +28,9 @@ public class CommonDelayMqConsumer {
|
||||
case 1:
|
||||
checkTimeOutJob.deal(dto.getRoomId());
|
||||
break;
|
||||
case 2:
|
||||
userForbidManager.checkAll();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user