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

Simon MacMullen simon at rabbitmq.com
Tue Nov 9 12:03:09 GMT 2010


On 08/11/10 08:21, jiri at krutil.com wrote:
> Simon,
>
>>> Can I close the connection from a channel shutdown listener?
>>
>> Not directly; it has the same problem. Of course, you could just spin
>> up a short-lived thread to do the closing in either case.
>
> It seems to work even when I close the connection directly in the thread
> that invoked the shutdown listener (of connection or channel).
>
> Can I leave it this way or am I programming by coincidence?

No, I was wrong. Now that I've actually looked at the code I see that 
Connection.close() has some magic in it to allow you to call it from any 
thread.

Cheers, Simon
-- 
Simon MacMullen
Staff Engineer, RabbitMQ
SpringSource, a division of VMware



More information about the rabbitmq-discuss mailing list