onkami
onkami

Reputation: 9441

Temporarily stop consuming RabbitMQ messages and resume later

I use Java's rabbitmq-client (https://mvnrepository.com/artifact/com.rabbitmq/amqp-client) and I need to implement the following scenario:

What would be the best way to implement pause/resume of listening from a RabbitMQ queue using the amqp-client Java library?

Upvotes: 4

Views: 10045

Answers (1)

Luke Bakken
Luke Bakken

Reputation: 9667

You don't mention which method you're using to consume messages, so I assume you are using basicConsume to subscribe to messages from a queue.

As that document mentions, you can use basicCancel to stop consuming from a queue. You would then use basicConsume when you wish to start again.

Be sure to use basicQos to set a reasonable prefetch count.

Upvotes: 2

Related Questions