Search code examples
rabbitmqeasynetq

EasyNetQ - Delayed messages with topics


Is there a way of publishing delayed messages with topics with EasyNetQ? I was able to send direct delayed messages using the FuturePublish method, but it doesn't allow me to specify a topic.

Links:

Scheduling Events with Future Publish

RabbitMQ gets support for delayed messages delivery

Thanks


Solution

  • It should be possible, yes. The delayed message exchange allows you to specify the type of exchange to use after the delay: fanout, topic, direct.

    Looking at the code samples in the second link you posted, you should only need to change the "direct" configuration to "topic".

    
    IDictionary args = new Dictionary
    {
        {"x-delayed-type", "topic"} //----------- here
    };
    channel.ExchangeDeclare("DelayedTest", "x-delayed-message", true, false, args);
    

    then follow the rest of the example as shown and you can publish with a topic for the routing key.