0

I am working on Azure ServiceBus Topic-Subscriptions. I created one topic and two subscriptions in Service Bus Namespace. In my current application, I am able to send messages to topic after that I receive messages by using subscribers.

But whenever one subscriber will read messages from topic then the messages are gone into Dead-Letter-Queue. That’s why second subscriber will be unable to read messages from topic.

I wrote this line in my code after process message from Topic

await subscriptionClient.CompleteAsync(message.SystemProperties.LockToken);

I followed this documentation for implementing above scenario.

So, can anyone suggest me how to read messages from topic using multiple subscribers at a time.

Pradeep
  • 5,101
  • 14
  • 68
  • 140

1 Answers1

0

whenever one subscriber will read messages from topic then the messages are gone into Dead-Letter-Queue. That’s why second subscriber will be unable to read messages from topic.

Either there's a processing logic error and message is retried until it gets moved to the dead-letter queue or you've got MaxDeliveryCount set to one processing attempt. Either way, check DeadLetterReason and DeadLetterErrorDescription headers/properties for the reason message got moved into dead-letter queue.

can anyone suggest me how to read messages from topic using multiple subscribers at a time.

Azure Service Bus supports competing consumer pattern, you don't have to do anything special.

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • @Thanks Sean, I set `Max Delivery Count` as 1 to my subscriber. And I checked DeadLetterReason in the DLQ which contains the message as `MaxDeliveryCountExceeded`. For example, If I have 3 subscribers in one Topic then I need to set 3 as `Max Delivery Count ` is it right? – Pradeep Mar 07 '19 at 06:25
  • Suggest to read up on the delivery mode [`PeekLock`](https://docs.microsoft.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read) and [competing consumers](https://docs.microsoft.com/en-us/azure/architecture/patterns/competing-consumers) pattern. Those are two different things that will help to understand how to use `MaxDeliveryCount` (accounting for failing processing, intermittent issues, etc) vs how brokered messages are consumed. If you want **each** subscriber to receive a message, you'll need to have a **subscription entity for each subscriber**. That's how pub/sub works. – Sean Feldman Mar 07 '19 at 15:59