Benjamin E. Benjamin E. - 14 days ago 5
C# Question

Dead letter queue not cleared

I have a few messages that were dead lettered automatically due to an exceeded retry count. Now I'm trying the re-queue them like this:

while ((msg = DeadLetterQueueClient.Receive()) != null)
{
var body = msg.GetBody<MyModel>();
QueueClient.Send(new BrokeredMessage(body));
}


I receive all dead lettered messages, however they don't clear from the queue. Every time I start this code, the same messages are received again.

What's wrong?

PS: The queue actually has dead lettering turned off, according to the old Azure portal. The messages only show up as dead lettered in Visual Studio Server Explorer and I also receive them with the above code.

Answer

Mark the message as complete and it should be deleted from the dead letter queue

while ((msg = DeadLetterQueueClient.Receive()) != null)
{
    var body = msg.GetBody<MyModel>();
    QueueClient.Send(new BrokeredMessage(body));
    msg.Complete();
}
Comments