In general, dead lettering means that there are messages in a queue considered as dead (because there was no receiver interested in pulling them) and you have two options to proceed:
- Either delete them permanently
- Push them to an additional queue, named a dead letter queue
In Azure Service Bus, you have two options to push a message to a dead letter queue:
- Set the maximum lifetime of a message—once it expires, it is automatically moved to a dead letter queue
- Use the DeadLetterAsync method on MessageReceiver as follows:
await receiver.DeadLetterAsync("<lock-token>", "<reason>");
Here you can find the complete example, and you can find a lock token:
while (true){ var message = await receiver.ReceiveAsync(); if(message == ...