测试rabbitMQ

This commit is contained in:
Guoqs
2024-11-05 16:44:26 +08:00
parent 5a1cf19699
commit 45a2920981
3 changed files with 54 additions and 10 deletions

View File

@@ -1,9 +1,11 @@
package com.jsowell.mq;
import com.jsowell.common.constant.RabbitConstants;
import com.jsowell.pile.dto.AfterSettleOrderDTO;
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.stereotype.Service;
import java.io.IOException;
@@ -16,7 +18,7 @@ public class OrderRabbitListener {
* 多线程消费请求消息
* @param message
*/
// @RabbitListener(queues = RabbitConstants.QUEUE_CHARGE_ORDER_DATA)
@RabbitListener(queues = RabbitConstants.QUEUE_CHARGE_ORDER_DATA)
public void receiveChargeOrderData(AfterSettleOrderDTO afterSettleOrderDTO, Channel channel, Message message) throws IOException {
log.info("接收到订单结算数据:{}", afterSettleOrderDTO);
//由于配置设置了手动应答所以这里要进行一个手动应答。注意如果设置了自动应答这里又进行手动应答会出现double ack那么程序会报错。