直播
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.cai.mq.consumer;
|
||||
|
||||
import com.ruoyi.cai.service.ConsumeLogService;
|
||||
import com.ruoyi.cai.ws.service.SettleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AmqpConsumer {
|
||||
|
||||
public final static String CALCULATE_SALES_QUEUE = "calculateSalesQueue";
|
||||
public final static String CALCULATE_SALES_EXCHANGE = "calculateSalesExchange";
|
||||
public final static String CALCULATE_SALES_KEY = "calculateSalesKey";
|
||||
|
||||
|
||||
/**
|
||||
* queuesToDeclare:支持多个队列,将队列绑定到默认交换机上,routeKey为队列名称。
|
||||
* @param msg 接收到的消息
|
||||
*/
|
||||
/**@RabbitListener(queuesToDeclare = @Queue(value = "testQueue"),containerFactory = "customContainerFactory")
|
||||
public void listener(String msg) {
|
||||
System.out.println(msg);
|
||||
}*/
|
||||
|
||||
@Autowired
|
||||
private ConsumeLogService consumeLogService;
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = CALCULATE_SALES_QUEUE, durable = "false", autoDelete = "false"),
|
||||
exchange = @Exchange(value = CALCULATE_SALES_EXCHANGE),
|
||||
key = CALCULATE_SALES_KEY)
|
||||
,containerFactory = "customContainerFactory")
|
||||
public void calculateSalesQueue(String message) {
|
||||
log.info("接受到到分销处理请求: message=" + message);
|
||||
consumeLogService.dealFenxiao(Long.valueOf(message));
|
||||
log.info("分销处理完成: message=" + message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.cai.mq.consumer;
|
||||
|
||||
import com.ruoyi.cai.mq.AmqpProducer;
|
||||
import com.ruoyi.cai.mq.CheckTimeOutMqConfig;
|
||||
import com.ruoyi.cai.ws.service.SettleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.index.qual.SameLen;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CheckTimeOutMqConsumer {
|
||||
@Autowired
|
||||
private SettleService settleService;
|
||||
@Autowired
|
||||
private AmqpProducer amqpProducer;
|
||||
|
||||
@RabbitListener(queues = CheckTimeOutMqConfig.QUEUE_NAME
|
||||
,containerFactory = "customContainerFactory")
|
||||
public void checkTimeOutMq(String message) {
|
||||
log.info("checkTimeOutMq: " + message);
|
||||
boolean next = settleService.withholdingFee(Long.valueOf(message));
|
||||
if(next){
|
||||
// 1分钟后继续执行
|
||||
amqpProducer.sendCheckTimeOut(message,60);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cai.mq.consumer;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.cai.mq.AmqpProducer;
|
||||
import com.ruoyi.cai.mq.CommonDelayDto;
|
||||
import com.ruoyi.cai.mq.CommonDelayMqConfig;
|
||||
import com.ruoyi.cai.ws.job.CheckTimeOutJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommonDelayMqConsumer {
|
||||
@Autowired
|
||||
private CheckTimeOutJob checkTimeOutJob;
|
||||
@Autowired
|
||||
private AmqpProducer amqpProducer;
|
||||
|
||||
@RabbitListener(queues = CommonDelayMqConfig.QUEUE_NAME
|
||||
,containerFactory = "customContainerFactory")
|
||||
public void checkTimeOutMq(String message) {
|
||||
log.info("CommonDelayMqConsumer: " + message);
|
||||
CommonDelayDto dto = JSON.parseObject(message, CommonDelayDto.class);
|
||||
switch (dto.getType()){
|
||||
case 1:
|
||||
checkTimeOutJob.deal(dto.getRoomId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user