Skip to content

RabbitMq client hangs on consumer connection dispose #874

@ig-sinicyn

Description

@ig-sinicyn

RabbitMq.Client: 6.1.0 + net.core 3.1

We have a sample that was expected to measure consumer throughput but instead it hangs on consumer connection dispose.
Full code: RabbitMqHangsOnDispose.zip

Problem part:

private static async Task<string[]> ReceiveAsync(
    IConnectionFactory connectionFactory,
    int parallelCount,
    int expectedCount)
{
    string[] result;
    using (var connection = connectionFactory.CreateConnection())
    {
        using (var channel = connection.CreateModel())
        {
            channel.BasicQos(0, (ushort) parallelCount, false);

            var completed = new TaskCompletionSource<string[]>();
            var consumer = new EventingBasicConsumer(channel);
            consumer.Received += (s, e) => ...
            var tag = channel.BasicConsume(...);
            result = await completed.Task;
            channel.BasicCancel(tag);

            Console.WriteLine("Before close channel");
        }

        Console.WriteLine("Before close connection");
    }                                                  // < hangs on Dispose() call

    Console.WriteLine("All closed - never called!");

    return result;
}

Expected behavior: connection disposal should complete successfully.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions