Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you delete the dead letters in an Azure Service Bus queue?

How do you delete the dead letters in an Azure Service Bus queue?

I can process the messages in the queue ...

var queueClient = QueueClient.CreateFromConnectionString(sbConnectionString, queueName);
while (queueClient.Peek() != null)
{
    var brokeredMessage = queueClient.Receive();
    brokeredMessage.Complete();
}

but can't see anyway to handle the dead letter messages

like image 592
SteveC Avatar asked Feb 05 '23 20:02

SteveC


1 Answers

The trick is to get the deadletter path for the queue which you can get by using QueueClient.FormatDeadLetterPath(queueName).

Please try the following:

var queueClient = QueueClient.CreateFromConnectionString(sbConnectionString, QueueClient.FormatDeadLetterPath(queueName));
while (queueClient.Peek() != null)
{
    var brokeredMessage = queueClient.Receive();
    brokeredMessage.Complete();
}
like image 197
Gaurav Mantri Avatar answered Apr 27 '23 15:04

Gaurav Mantri