Skip to content

Commit 15c0831

Browse files
Add a test for #61
1 parent 05d1460 commit 15c0831

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

projects/client/Unit/src/unit/TestConsumerOperationDispatch.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
//---------------------------------------------------------------------------
4040

4141
using NUnit.Framework;
42+
using RabbitMQ.Client.Events;
4243
using RabbitMQ.Client.Framing;
4344
using System;
4445
using System.Collections.Generic;
@@ -149,6 +150,33 @@ public void TestDeliveryOrderingWithSingleChannel()
149150
}
150151
}
151152

153+
// see rabbitmq/rabbitmq-dotnet-client#61
154+
[Test]
155+
public void TestChannelShutdownDoesNotShutDownDispatcher()
156+
{
157+
var ch1 = Conn.CreateModel();
158+
var ch2 = Conn.CreateModel();
159+
Model.ExchangeDeclare(x, "fanout", durable: false);
160+
161+
var q1 = ch1.QueueDeclare().QueueName;
162+
var q2 = ch2.QueueDeclare().QueueName;
163+
ch2.QueueBind(queue: q2, exchange: x, routingKey: "");
164+
165+
var latch = new ManualResetEvent(false);
166+
ch1.BasicConsume(q1, true, new EventingBasicConsumer(ch1));
167+
var c2 = new EventingBasicConsumer(ch2);
168+
c2.Received += (object sender, BasicDeliverEventArgs e) =>
169+
{
170+
latch.Set();
171+
};
172+
ch2.BasicConsume(q2, true, c2);
173+
// closing this channel must not affect ch2
174+
ch1.Close();
175+
176+
ch2.BasicPublish(exchange: x, basicProperties: null, body: encoding.GetBytes("msg"), routingKey: "");
177+
Wait(latch);
178+
}
179+
152180
private class ShutdownLatchConsumer : DefaultBasicConsumer
153181
{
154182
public ManualResetEvent Latch { get; private set; }

0 commit comments

Comments
 (0)