具有多个侦听器的天蓝色服务总线队列/具有队列的竞争消费者 [英] azure service bus queue with multiple listeners / competing consumers with queue

查看:76
本文介绍了具有多个侦听器的天蓝色服务总线队列/具有队列的竞争消费者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从理论上讲,相对于消息和接收者,蔚蓝服务总线队列看起来是一对一的. 只是想知道队列中是否可以有多个侦听器.

Theoretically it looks like azure service bus queues is one to one with respect to message and receiver. Just wanted to know if it's possible to have more than one listeners to a queue.

如果为1:1,是否意味着要实现竞争性的消费者模式,我们就不能使用队列,而主题是唯一的选择吗?

If it is 1:1, does it mean to realize competing consumers pattern we cannot use queues, and topics is the only option?

推荐答案

队列和主题之间有很大的区别:对于队列,每条消息仅由 1个使用者接收.有了主题,订阅该主题的每个消费者都会收到每条消息(尽管仍有过滤的余地...).如果您的方案要求每条消息仅由一个使用者处理,请使用队列.如果所有已注册的流程都需要处理,请使用主题.

There is a big difference between queues and topics: with queues, each message is picked up by only 1 consumer. With a topic, every consumer that subscribed to the topic will get each message (although there is room to filter...). If your scenario requires each message to be processed by only one consumer, use queues. If all of the registered processes need to work on it, use topics.

可以有多个侦听器到一个队列.假设我们有同时监听队列的流程A和流程B.出现一条消息,进程A接听该消息.如果收到另一条消息,而进程A尚未完成,则进程B将接听该消息.如果进程A准备就绪,则任何一个进程都可以接收第二条消息.

You can have multiple listeners to a queue. Let's say we have Process A and Process B that both listen to the queue. A message comes in, and Process A picks it up. If another message comes in and Process A hasn't finished yet, Process B will pick up the message. If Process A is ready, either one of the processes can pick up the second message.

有关竞争消费者的更多信息,请查看 《 Azure体系结构中心》上的竞争消费者" 文章,其中包含(参考)示例代码.

For more info on competing consumers, have a look at the Competing Consumers article on the Azure Architecture Center, complete with (references to) example code.

这篇关于具有多个侦听器的天蓝色服务总线队列/具有队列的竞争消费者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆