6.4 将mq抽取为公共方法写在common中

This commit is contained in:
zhangsan 2025-06-04 16:34:39 +08:00
parent 9b61eb1018
commit 487d847bf2
2 changed files with 5 additions and 3 deletions

View File

@ -8,4 +8,5 @@ public interface MQConstants {
//支付成功消息的交换器和路由键
String PAY_EXCHANGE_NAME = "pay.direct";
String PAY_SUCCESS_ROUTING_KEY = "pay.success";
String PAY_SUCCESS_QUEUE_NAME = "trade.pay.success.queue";
}

View File

@ -1,5 +1,6 @@
package com.hmall.trade.listener;
import com.hmall.common.constants.MQConstants;
import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -17,9 +18,9 @@ public class PayStatusListener {
private final IOrderService orderService;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = "trade.pay.success.queue", durable = "true"),
exchange = @Exchange(name = "pay.direct"),
key = "pay.success"
value = @Queue(name = MQConstants.PAY_SUCCESS_QUEUE_NAME, durable = "true"),
exchange = @Exchange(name = MQConstants.PAY_EXCHANGE_NAME),
key = MQConstants.PAY_SUCCESS_ROUTING_KEY
))
public void listenPaySuccess(Long orderId){
orderService.markOrderPaySuccess(orderId);