Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ - Close Idle/dangling channels

I have a multi-threaded application that publishes incoming messages to a rabbitmq exchange. Using the rabbitmq java client, I create a single rabbitmq connection at application startup and share it across all my threads. Each thread creates a new channel (threadlocal) so that the channels are not shared across multiple threads as recommended by the rabbitmq documentation. I am using netty and I see the same number of rabbitmq channels being created as netty channel pipeline threads. So far so good.

However, I have a keep alive time of 2 mins on my netty threads (I need this and cannot change it). So, if a thread is idle for 2 mins it dies. However, the channel associated to the thread isn't killed and remains idle until the connection closes. Thus, I get an increasing list of channels that are IDLE and never get closed. I did not see anything in rabbitmq documentation that addresses the issue of dangling channels. Is there a way for me to close a channel that has been idle for a period of time? If not, what's the best alternative to resolve this?

like image 319
NewLight Avatar asked Jun 22 '14 18:06

NewLight


1 Answers

Actually there is no way to close the channel from the web-console as the channel is bound to the connection. So what you can do is go to the Connections tab, click on the connection (it has same id as the channel, so it's easy to identify) and on the opened page click Force Close

like image 84
Konstantin Chernov Avatar answered Sep 22 '22 22:09

Konstantin Chernov