|
39 | 39 | //---------------------------------------------------------------------------
|
40 | 40 |
|
41 | 41 | using NUnit.Framework;
|
| 42 | +using RabbitMQ.Client.Events; |
42 | 43 | using RabbitMQ.Client.Framing;
|
43 | 44 | using System;
|
44 | 45 | using System.Collections.Generic;
|
@@ -149,6 +150,33 @@ public void TestDeliveryOrderingWithSingleChannel()
|
149 | 150 | }
|
150 | 151 | }
|
151 | 152 |
|
| 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 | + |
152 | 180 | private class ShutdownLatchConsumer : DefaultBasicConsumer
|
153 | 181 | {
|
154 | 182 | public ManualResetEvent Latch { get; private set; }
|
|
0 commit comments