0

I'm trying to implement priority messages using multiple queues (four in my case) with RabbitMQ and EasyNetQ.

I understand that IBus instance should be kept alive for the whole application life cycle. Also, the only way to stop RabbitMQ from sending more messages on a given queue is to dispose of the IBus using Dispose.

Given these two contradicting factors how should I architect this? One IBus instance per queue and if messages on the more important queue are being sent disposing (and later recreating) of the less important ones?

Marcin Waligora
  • 548
  • 4
  • 11

1 Answers1

1

Prioritisation isn't something that's available out-of-the-box with EasyNetQ/RabbitMQ, so there's no easy answer to this question. You can cancel subscriptions without disposing of IBus, by using the consumer cancellation feature:

var consumer = bus.Subscribe<MyMessage>( ....
...
// stop consuming:
consumer.Dispose();

But I really don't think that this is the answer to designing a prioritisation system. You'd be better off using the raw RabbitMQ.Client and designing your own IBasicConsumer implementation that consumes from all four queues and has the prioritisation algorithm coded into it. Quite advanced stuff I'm afraid.

Mike Hadlow
  • 9,427
  • 4
  • 45
  • 37
  • Thanks Mike. You're right that was not the right way to go around this. There's a much simpler solution. RabbitMQ offers Priority queues with this plugin: rabbitmq/rabbitmq-priority-queue : [https://github.com/rabbitmq/rabbitmq-priority-queue] – Marcin Waligora Aug 05 '14 at 05:02