RabbitMQ - Close Waiting / Dangling Channels

I have a multi-threaded application that publishes incoming messages to a rabbit exchange. Using the rabbitmq java client, I create one rabbitmq connection when the application starts and dividing it across all my threads. Each thread creates a new channel (threadlocal) so that the channels are not distributed among multiple threads, as recommended in the rabbitmq documentation. I use netty, and I see the same number of rabbitmq channels that are created as netty thread threads. So far, so good.

However, I have a 2 minute wait time on my netty threads (I need it and cannot change it). So, if the thread is idle for 2 minutes, it dies. However, the channel associated with the stream is not killed and remains inactive until the connection is closed. This way I get a list of channels that are IDLE and never close. I have not seen anything in the rabbitmq documentation that addresses the dangling channel issue. Is there a way to close a channel that has been idle for a while? If not, what is the best alternative to solve this problem?

+4
source share
3 answers

-, . , , Connections, ( , , ), Force Close

+2

. , , . .

    if (cancellationToken.IsCancellationRequested)
    {
         logger.InfoFormat("Cancellation requested, stopping case processor.");

         // 320: connection-forced
         channel.Close(320, "Service stopped");
     }
0

Source: https://habr.com/ru/post/1545583/


All Articles