Azure ServiceBus: all topic subscribers must process message
Asked Answered
A

3

7

I'm just starting to use Azure ServiceBus. One thing is not fully clear to me, and I'm having a hard time finding an answer.

If I call message.Complete() on a subscription message, does that mean that this message will not be delivered to any other subscribers anymore, or am I only completing this message for the current subscriber? In other words, does the service bus keep track of messages per subscriber, or per subscription?

In my particular use case, I would want the message to be processed by all subscribers, not just by any/one subscriber. Is this at all possible with topics?

Ankylosaur answered 18/2, 2017 at 15:23 Comment(0)
D
5

Message is intended to be processed by a single competing consumer. Otherwise it would be considered a message duplication.

If you need to send the same message to multiple instances of the same logical subscriber, each subscriber has has to have it's own dedicated subscription queue with a default filter.

For example: when using Cloud Services, you'd need to create a subscriber per instance of CS role. Each subscription queue needs to be uniquely identifiable and unique identifier has to be deterministic. One option would be either to use CS instance ID. Whenever process scales out, instance ID would be appended to subscription queue. There's also a challenge with this approach. When process scales in, there might be remaining unprocessed messages.

Delbert answered 19/2, 2017 at 17:37 Comment(0)
B
11

Your question was already answered, but there seem to be a confusion in terms (subscription\subscriber), and what's the recommended use case.

Consider a simple queue where in one end you put messages, and on the other end you pop them. This is how a ServiceBus queue behaves.
Now consider a queue where you still put messages in one end, but then it splits onto multiple ends that you can pop messages from. This describes a topic (where you put messages) and a subscription (where you pop messages).

In a topic\subscription, the messages in the topic are copied to the subscription. So each subscription is independent of the other subscription. It's like a different copy of the queue.

Now, your client applications that are receiving messages from a subscription are what you called subscribers. Each client (subscriber) is meant to connect to a single subscription. In this case, subscribers do not compete for messages, and each subscriber can process the same message as others did.

On the other hand, if you have many client applications (subscribers) that connect to the same subscription, then naturally they all compete for the same messages.

Hopefully this explained the answers you got (which appear to be conflicting but really just use same terms differently). Bottom line is eventually you can do both scenarios with ServiceBus.

Booklover answered 19/2, 2017 at 19:4 Comment(0)
D
5

Message is intended to be processed by a single competing consumer. Otherwise it would be considered a message duplication.

If you need to send the same message to multiple instances of the same logical subscriber, each subscriber has has to have it's own dedicated subscription queue with a default filter.

For example: when using Cloud Services, you'd need to create a subscriber per instance of CS role. Each subscription queue needs to be uniquely identifiable and unique identifier has to be deterministic. One option would be either to use CS instance ID. Whenever process scales out, instance ID would be appended to subscription queue. There's also a challenge with this approach. When process scales in, there might be remaining unprocessed messages.

Delbert answered 19/2, 2017 at 17:37 Comment(0)
A
1

So, apparently it isn't possible. Subscribers to the same subscription compete for handling of the message, and cannot all process the same message. Separate subscriptions are required for that.

This question is more or less a duplicate of Azure Service Bus - subscribers can independently subscribe to a subscription and share the same message?

Ankylosaur answered 18/2, 2017 at 20:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.