[rabbitmq-discuss] The idiom for shutting down a consumer in a thread task

Mark Petrovic mspetrovic at gmail.com
Mon Jan 16 14:43:07 GMT 2012


I'm looking for the idiom for how to gracefully shutdown a consumer
running in a Java thread.  Given a Runnable's run() method that looks
like this

    public void run() {
        while (doConsume) {
            try {
                channel.basicConsume(queue, false, busReader);
            } catch (IOException e) {
                throw new RuntimeException("Error in reader", e);

what is the recommended way to cancel this logical task?  Call
connection.close() and exit out the catch-block?

Thank you.


More information about the rabbitmq-discuss mailing list