What is the best way to maintain a solid queue and bindings, but to suspend its users?
Use case: I would like to βlet it crashβ and stop processing messages if we continue to receive a bunch of messages that we cannot deal with (for example, the database does not work or a problem with the schema), but I would like to keep the aggregation in the queue . This allows you to publish, but pause consumption.
I can present three solutions:
- I could have all the consumers associated with the queue continuously reject messages and reorder, but these are kind of unnecessary resources, not to mention the fact that I programmatically execute the above logic.
- I could call
basic.cancelConsumer for all consumers (see below) - Or in terms of spring-amqp, I assume that I could call
shutdown on all SimpleMessageListenerContainers that are queued.
#1 we already do, as messages are rejected. The problem is that it ends up like an endless loop cycle, and if your log does not allow you to get more resources wasted.
#3 seems perfect, but I need to know how they know about all message listeners, and then notify them of the disconnect. I suppose I could use a branching exchange to inform that the queue should be suspended. I feel that RabbitMQ should have something built-in for this logic. Another problem is that you can associate multiple queues with a message container (not all queues can be suspended).
For #2 I know that to cancel the user with his consumerTag , but the question (assuming this is the right way to do the above), where can I get the list of consumerTag in the queue?
source share