1

It is possible to set up TTL for messages in Azure Service Bus. I am wondering if there is a possibility to do the same for Dead Letter Queue?

What I want to achieve is "auto-cleaning" of the DLQ of the old messages that are probably not relevant anymore anyway, so that we don't need to do this manually (which is not supported out of the box either).

Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207

1 Answers1

1

What I want to achieve is "auto-cleaning" of the DLQ of the old messages that are probably not relevant anymore anyway so that we don't need to do this manually (which is not supported out of the box either).

You can receive and delete messages from the dead-letter queue, but you cannot set up a TTL on the dead-lettered messages as those are created and moved into the sub-queue by the service. While the dead-letter queue mimics the regular queue in many concepts, it is not.

One of the semi-automated would be to create a process that peeks messages and completes based on the criteria you define, such as message age. Unfortunately, there's no good way to peek at messages in general. Not much can be done for the dead-lettered messages, other than peeking all and then filtering out those that need to be actioned.

Another alternative is to transition those dead-lettered messages into a database and then have a process to retire based on the defined criteria without the need to peek at all of the messages constantly.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • Thanks for the answer! I assume the only way would be to run some kind of Serivce / Azure Function and write the code myself as it seems there is no built-in way of doing it (from your answer). – Ilya Chernomordik Dec 30 '21 at 08:11
  • 1
    Indeed. Function is likely the simplest way to achieve it. The reason I brought the idea of moving DLQ-ed messages to a database is to be be able to have more robust search instead not peeking band paying each time for that. All depends on the messages volume and scenario you have. – Sean Feldman Dec 30 '21 at 14:09