0
votes

I am using Microsoft Azure Service Bus for .NET Standard.

I'm reading messages from a Service Bus queue using multiple consumers(multiple instances of MessageReceiver) with PeekLock read.

I am not completing the receiving operation for the messages in order for them to be deleted from the queue.

The problem is that the deliveryCount for the second message is basically the deliveryCount for the first message(usually 1) + 1, so 2. Somehow the deliveryCount is passed from one message to another. This problem doesn't occur when I receive both messages with the same receiver(_messageReceiver1 or _messageReceiver2).

msg1 = await _messageReceiver1.ReceiveAsync(80); Writeline(msg1.SystemProperties.DeliveryCount);

msg2 = await _messageReceiver2.ReceiveAsync(80); Writeline(msg2.SystemProperties.DeliveryCount);

After exceeding the max delivery count from the portal, because of the delivery count being passed from one message to another, all of my messages are sent to DLQ, even if I was trying to read them or not.

1

1 Answers

0
votes

You should go with Topic Subscriptions for multiple consumers. Receiving the messages multiple times will increase the delivery count of the message. Once the count increased more then the Max Delivery Count of the Queue, the messages will be moved to Dead Letter Queue.