update rabbit消息结算订单

This commit is contained in:
Guoqs
2024-11-06 15:18:37 +08:00
parent ac33d967f8
commit 60154da1bf
3 changed files with 17 additions and 23 deletions

View File

@@ -1,11 +1,14 @@
package com.jsowell.mq;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.common.constant.RabbitConstants;
import com.jsowell.pile.dto.AfterSettleOrderDTO;
import com.jsowell.pile.service.OrderBasicInfoService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -16,6 +19,8 @@ import java.io.IOException;
@Slf4j
@Service
public class OrderRabbitListener {
@Autowired
private OrderBasicInfoService orderBasicInfoService;
/**
* 多线程消费请求消息
@@ -24,6 +29,13 @@ public class OrderRabbitListener {
@RabbitListener(queues = RabbitConstants.QUEUE_CHARGE_ORDER_DATA)
public void receiveChargeOrderData(AfterSettleOrderDTO afterSettleOrderDTO, Channel channel, Message message) throws IOException {
log.info("接收到订单结算数据:{}", afterSettleOrderDTO);
try {
orderBasicInfoService.realTimeOrderSplit(afterSettleOrderDTO);
} catch (BaseAdaPayException e) {
throw new RuntimeException(e);
}
//由于配置设置了手动应答所以这里要进行一个手动应答。注意如果设置了自动应答这里又进行手动应答会出现double ack那么程序会报错。
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
}