Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to peek the deadletter messages

It is very hard to find some good documentation on getting all the messages in a deadletter queue and getting to take a peek at them.

I have an Azure Servicebus Queue and everything I can find is for Azure Servicebus Topics.

Can someone help me with a quick guide?

like image 577
Simon Sondrup Kristensen Avatar asked Oct 23 '25 19:10

Simon Sondrup Kristensen


1 Answers

Dead letter queue is a secondary sub-queue where the poison messages are moved to.

In case of Azure Servicebus Queue the standard path for DLQ is queuePath/$DeadLetterQueue. So you need to have another queueClient to read the DLQ.

And you will do something like this in .NET clients.

string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var client = QueueClient.CreateFromConnectionString(connectionString, "QueueName");

// do whatever regular queue reading activities

// this is for dead letter queue
var deadLetterClient = QueueClient.CreateFromConnectionString(connectionString, QueueClient.FormatDeadLetterPath(client.Path), ReceiveMode.ReceiveAndDelete);

BrokeredMessage receivedDeadLetterMessage;
while ((receivedDeadLetterMessage = deadLetterClient.Receive(TimeSpan.FromSeconds(10))) != null)
{
    Console.WriteLine(receivedDeadLetterMessage);
}
like image 100
Aravind Avatar answered Oct 25 '25 19:10

Aravind



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!