rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 353 forks source link

Send message from a handler to Service Bus Azure DLQ #1117

Closed OmarVoxel closed 9 months ago

OmarVoxel commented 9 months ago

Hello, I was wondering if 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?

OmarVoxel commented 9 months ago

Update!

I wanted to send it to the DLQ directly because I didn't know how stop the retrying stuff, today I saw there's IFailFastException so this solved my problem.

mookid8000 commented 9 months ago

Hi @OmarVoxel , as I explained to you here on StackOverflow, Rebus does not use Azure Service Bus' built-in dead-letter queue mechanism, because it's not an ordinary queue, and other queueing systems (e.g. like RabbitMQ, Azure Storage Queues, AmazonSQS, ...) don't have a similar concept.

Instead, Rebus just creates an ordinary queue (by default named "error"), which it will use as its dead-letter queue.

When you

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

Rebus will simply forward the transport message currently being handled to that queue.

Using an ordinary queue as the dead-letter queue has the big advantage that it's just an ordinary queue! So what you can do with all other queues, you can also do with the "error" queue, e.g. start a Rebus instance that consumes messages from it, if that would make sense for you.

Since I believe this has now been thoroughly explained in multiple places I will just go ahead an close this issue 🙂