Creating new channels after RabbitMQ connection was blocked

298 Views Asked by At

I have a very basic demo application for testing the RabbitMQ blocking behaviour. I use RabbitMQ 3.10.6 with the .NET library RabbitMQ.Client 6.2.4 in .NET Framework 4.8.

The disk is filled until the configured threshold in the RabbitMQ config file is exceeded. The connection state is "blocking".

I queue a message this way: AMQP properties are added to the message using channel.CreateBasicProperties() with Persistent = true. It is then queued:

sendChannel.BasicPublish("", "sendQueueName", amqpProperties, someBytes);
sendChannel.WaitForConfirmsOrDie(TimeSpan.FromSeconds(5));

WaitForConfirmsOrDie() closes the underlying channel when the broker is blocking or blocked. Because this is the case the channel is closed and I need to create a new one if I want to queue messages again.

The connection state is "blocked".

First example: I catch the TimeoutException that is thrown, remove the resource alarm by providing enough disk space and create a new channel in the catch block. This works.

Second example: I catch the TimeoutException that is thrown but do nothing in the catch block. I remove the resource alarm by providing enough disk space and wait for the ConnectionUnblocked event to be fired. In here I create a new channel. But here it doesn't work. I get a TimeoutException.

Why can't I create any more channels outside the catch block once the connection was blocked?

The connection is created using ConnectionFactory.CreateConnection() and uses AutomaticRecoveryEnabled = true (although this doesn't seem to make any difference).

A channel is created using Connection.CreateModel().

0

There are 0 best solutions below