(RabbitMQ 五)SpringBoot+RabbitMQ一个接收者监听多个消息队列

SpringBoot+RabbitMQ一个接收者监听多个消息队列


RabbitMQ系列文章如下:

(RabbitMQ 一【转载】)windows10环境下的RabbitMQ安装步骤
https://blog.csdn.net/myQNUMNINE/article/details/120447514

(RabbitMQ 二)Springboot项目中使用RabbitMQ的相关依赖
https://blog.csdn.net/myQNUMNINE/article/details/120460073

(RabbitMQ 三)SpringBoot+RabbitMQ实现发送和接收队列(可接受基本数据类型和对象)
https://blog.csdn.net/myQNUMNINE/article/details/120053242

(RabbitMQ 四)SpringBoot+RabbitMQ实现用接收器接受多个主题【一条消息通过交换机发往多个消息队列】
https://blog.csdn.net/myQNUMNINE/article/details/120065706

(RabbitMQ 五)SpringBoot+RabbitMQ一个接收者监听多个消息队列
https://blog.csdn.net/myQNUMNINE/article/details/120096394

(RabbitMQ 六)SpringBoot+RabbitMQ实现广播模式
https://blog.csdn.net/myQNUMNINE/article/details/120095529

(RabbitMQ 七【完结】)SpringBoot+RabbitMQ实现消息队列延迟功能(使用RabbitMQ延迟插件实现)
https://blog.csdn.net/myQNUMNINE/article/details/120335005


很简单,多用一次@RabbitListener注解多监听一个即可。

接收者类的代码如下:

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component 
@RabbitListener(queues = "object")
@RabbitListener(queues = "object2")
public class ObjectReceiver {

	@RabbitHandler
	public void process(User user) {
		System.out.println("对象接收者-Receiver object:"+user.toString());
	}
}

以上代码实现了监听object和object2两个消息队列

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值