[rabbitmq-discuss] Java client: Closing channel in channel shutdown listener

jiri at krutil.com jiri at krutil.com
Wed Nov 3 15:39:13 GMT 2010


Simon,

> Hi Jiri. The shutdown listener is invoked by the connection's  
> mainloop thread, so it can't in itself do anything that involves  
> sending data over the connection (which includes closing channels).

OK. Can I close the connection from a channel shutdown listener?

> Do you need to close channels? If the error is hard, the connection  
> will be closed and implicitly all channels will close; if the error  
> is soft only the channel that caused the error will close and the  
> others will keep working.

I have a few long-lived channels in my app. If any of them gets closed  
due to an error (maybe I attempt to publish to a nonexistent  
exchange), I want to close everything, re-connect and re-open my  
channels. This is to avoid a situation when a closed channel causes  
that part of the app does not work, trying to use a closed channel  
over and over again.

So I guess the easiest way to go for me is: in the channel shutdown  
listener, close the connection without trying to close channels, then  
re-connect.

Do you see any problem in that approach?

Many thanks
Jiri



More information about the rabbitmq-discuss mailing list