Search code examples
c#.netrabbitmqmessage-queueeasynetq

Custom Error Queue Name when using EasyNetQ for RabbitMQ?


Rather than having my unhandled exceptions go into EasyNetQ_Default_Error_Queue I wondered if there is a way that I can explicitly state the name of an Error Queue that should be used for a given application, so errors don't ALL end up in this one EasyNetQ_Default_Error_Queue?

I can see how to specify regular message queue names but haven't managed to find anything about Error Queue names.


Solution

  • Yes, you can customize the naming conventions by overriding the delegates on the IConventions object (or just create your own implementation of it and register that as a dependency):

    https://github.com/EasyNetQ/EasyNetQ/blob/master/Source/EasyNetQ.Tests/ConventionsTests.cs

    This should probably work:

    var bus = RabbitHutch.CreateBus("host=localhost");
    bus.Advanced.Container.Resolve<IConventions>().ErrorExchangeNamingConvention = info => "MyExchangeNaming";
    bus.Advanced.Container.Resolve<IConventions>().ErrorQueueNamingConvention = () => "MyErrorQueueNaming";