How do I stop consuming in RabbitMQ with Java and Python clients?
java, pika, python, rabbitmq
Solution
The counterpart of `basic_consume` is `basic_cancel`. `basic_cancel` will fire the provided `on_basic_cancel_ok` callback function when rabbitmq has done the cancelation. Be prepared for a short period where you may still receive some messages.
See: Pika Channel
Problem
I have both Java and Python clients that I use `channel.basicConsume()`. At some point I would like to stop those consumers without stopping the entire program. In Python with Pika I have put `channel.stop_consuming()` calls in place, but those generate errors that I am ignoring. Seems to work In Java I am not sure how to do this since stop_consume() doesn't appear to be available. All the documentation I see talks about all the ways to create consumers, but I can't seem to find anything that shows how to stop them. What is the best way to go about this?