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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With