Exclusive access to queues
RabbitMQ doesn’t allow us to see which messages are in the queue without consuming them. Because of that, when you click on a queue in QueueExplorer, it consumes messages, and after that sends “Nack” to RabbitMQ, which returns all these messages back to the queue. Problem is what happens when another application also consumes messages from that same queue at the same time?
There are two ways applications (including QueueExplorer) can receive messages from a queue:
Non-exclusive mode
When multiple applications receive messages from the same queue, they will “compete” for consuming and each of them will get only a subset of messages. If your application needs to process messages in correct order, you should not open that queue from QueueExplorer in Non-exclusive mode while application is running! It could get some newer messages first, and older ones later, when QueueExplorer releases them.
Exclusive mode
In this mode, only one application can consume messages from a queue at a time. Requests from other applications will be rejected with error message. QueueExplorer keeps queue in exclusive mode only while reading messages. After that, queue can be freely accessed by other applications.
Benefits of exclusive mode:
- There are no conflicting receives between QueueExplorer and other applications.
- We can use much faster “BasicConsume” instead of “BasicGet” RabbitMQ method. Multiple time faster in some cases.
Drawbacks of exclusive mode:
- If there’s already an application which consumes messages from a queue, QueueExplorer won’t be able to access it.
- While QueueExplorer keeps queue “locked”, other applications can’t receive messages from it.
How to change
RabbitMQ access mode can be changed globally from “View/Preferences” menu, RabbitMQ tab, “Exclusive consumer” checkbox.
Recommendations
- Use exclusive mode if possible, since it’s faster and eliminates risk of competing consumers.
- Reduce max number of messages QueueExplorer reads, using “List: Show Top 100” (or 1000) from toolbar. That reduces time for potential conflicts or while queue is locked.