Search code examples
nservicebus

How do I put a message on a RabbitMQ queue and just leave it there?


I've tried practically every setting I can find in the documentation and I can't seem to get a message to just sit in a queue (aside from the error queue).

I've tried:

transport.UsePublisherConfirms(false);

and

SendOptions().RequireImmediateDispatch();

and

EndpointConfiguration().DisableDurableMessages();

Nothing seems to work. If there's no handler, it just kicks back until it ends up in the error queue.


Solution

  • First of all I'm really curious on what you're trying to achieve here. Because why would you want a message to stay in a queue forever? It would be really helpful if you could provide information on that, because there might be a much better solution. Is there already an endpoint running on top of this queue? Do you want to send messages before the handlers are deployed, so that when it's deployed it will start processing messages?

    What you might want to do, is create a custom retry policy which retries it until forever : https://docs.particular.net/nservicebus/recoverability/custom-recoverability-policy#implement-a-custom-policy

    But think of the implications of that, before actually doing this. The endpoint will keep on trying this and other messages will get processed slower and slower, depending on the number of continuously retried messages in the queue.