[rabbitmq-discuss] need to close Channel, Connection

Simon MacMullen simon at rabbitmq.com
Mon Nov 12 10:03:55 GMT 2012


On 10/11/2012 8:50PM, John Cartwright wrote:
> In going through the tutorials
> (http://www.rabbitmq.com/getstarted.html), it appears that in cases
> where an infinite loop is used to listen for incoming messages (e.g.
> Worker.java) that the Connection and Channel are not explicitly closed
> when the program is terminated with a control-C.
>
> Is this acceptable behavior to use routinely?

Hi.

It's somewhat acceptable. If you close the connection explicitly then 
you know that every message you have published / every ack you have sent 
will have been received by the server by the time the close method returns.

If you just kill the program then that won't be true - in-flight 
publishes may be lost (obviously any that have been confirmed won't be). 
In-flight acks may also be lost (and hence the messages they are 
acknowledging will be redelivered). The server will log a warning. But 
that's all.

Cheers, Simon



More information about the rabbitmq-discuss mailing list