azure service bus queue with multiple listeners / competing consumers with queue

前提是你 提交于 2020-08-24 06:57:25

问题


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.

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.

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.

Competing consumers

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.



来源:https://stackoverflow.com/questions/53277200/azure-service-bus-queue-with-multiple-listeners-competing-consumers-with-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!