azureservicebusrebus

Rebus, send message to Services Bus Azure DLQ


Is there any way to send a Message to a DLQ in Service Bus Azure?

I have tried

await bus.Advanced.TransportMessage.Deadletter(errorDetails: "Let's hope it works");

but it didn't work. I assume this method send the message to the Rebus' QueueError, if so, is there any way to move the messages from this QueueError to the DLQ?


Solution

  • The following method call

    await bus.Advanced.TransportMessage.Deadletter(errorDetails: "Let's hope it works");
    

    will move the message currently being handled to Rebus' error queue. Rebus' error queue is an ordinary queue called "error", which it will automatically create when started.

    The reason Rebus does not use Azure Service Bus' deadletter queue, is that if it did, it would behave differently when running on ASB compared to all other transports, since ASB's built-in deadletter queue works in a slightly different way that an ordinary queue.

    E.g. using an ordinary queue called "error" means that you can start Rebus up with "error" as its input queue and have it consume the failed messages, because it's really just normal messages sitting in a normal queue (they just happen to have error details attached in a special header).

    I hope it's more clear now. 🙂

    --

    UPDATE: Here's how it looks when checking out the queues in the Azure Portal 👇

    Screenshot of the queues of Rebus' test ASB instance

    (in this case showing Rebus' test namespace that has a dead-letter queue called "error" currently containing one failed message)