0

I want to get the count of the messages from an Azure Service Bus Queue, using the SessionId of the messages.
I found how to count them without filtering by Session IDs here - Get queue message count using Microsoft.Azure.Management.ServiceBus, but I really need to count the messages with a specific SessionId.

1
  • You could try using ServiceBusReceiver.PeekMessagesAsync(maxMessages) (see MS doc), but you would have to provide the number of messages to be peeked (which may not be suitable for your use case?). I'm not aware of another solution than to peek due to the receive&delete or peek lock behavior of service bus queues. Commented Mar 8, 2022 at 22:12

1 Answer 1

0

You can get the count of the messages from an Azure Service Bus Queue as said, but by using the particular SessionId you cannot get the messages count.

The Azure.Messaging.ServiceBus. ServiceBusSessionReceiver is responsible for receiving ServiceBusReceivedMessage and settling messages from session-enabled Queues and Subscriptions.

public class ServiceBusSessionReceiver : 
Azure.Messaging.ServiceBus.ServiceBusReceiver

By using the default Properties of this class, we can get the details of SessionId and others like PrefetchCount, IsClosed etc..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.