C# How to receive a Message from Service Bus Queue and Deadletterqueue with Sequence Number

Tobias Wehrle 1 Reputation point
2022-09-08T08:29:22.643+00:00

I want to create my own Monitoring Tool for an Service Bus Queue. To Delete an specific Message in the normal Queue and Deadletterqueue, I need to receive a Message by a Sequence Number. But I can't find a such Method in my Receiver Object. I see a Method to Peek Messages with a Sequence Number, but i can't Complete them and its also not possible on Deatletter Messages. Is there a such Method to get Messages by Sequence Number?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
542 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 20,826 Reputation points
    2022-09-13T06:31:13.95+00:00

    Hi @Tobias Wehrle Thanks for reaching out. This feature is not available as of today, you can only receive messages by sequence number if those are in a "deferred state". For more information refer https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-deferral
    One workaround would be to receive all messages from the queue, then send to the DLQ the ones that would like to delete if you're looking forward deleting a specific message inside the DLQ, then you will need to receive them all, and then defer the one that you would like to delete, then use the receive deferred message method to remove it.

    Feel free to leave your feedback on our feedback page https://feedback.azure.com/d365community/forum/79b1327d-d925-ec11-b6e6-000d3a4f06a4

    let me know incase of further queries, I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments