public void TestCreateModelOnClosedAutorecoveringConnectionDoesNotHang() { // we don't want this to recover quickly in this test AutorecoveringConnection c = CreateAutorecoveringConnection(TimeSpan.FromSeconds(20)); try { c.Close(); WaitForShutdown(c); Assert.IsFalse(c.IsOpen); c.CreateModel(); Assert.Fail("Expected an exception"); } catch (AlreadyClosedException) { // expected } finally { StartRabbitMQ(); if (c.IsOpen) { c.Abort(); } } }
public void TestBasicConnectionRecoveryStopsAfterManualClose() { Assert.IsTrue(_conn.IsOpen); AutorecoveringConnection c = CreateAutorecoveringConnection(); var latch = new AutoResetEvent(false); c.ConnectionRecoveryError += (o, args) => latch.Set(); StopRabbitMQ(); latch.WaitOne(30000); // we got the failed reconnection event. bool triedRecoveryAfterClose = false; c.Close(); Thread.Sleep(5000); c.ConnectionRecoveryError += (o, args) => triedRecoveryAfterClose = true; Thread.Sleep(10000); Assert.IsFalse(triedRecoveryAfterClose); StartRabbitMQ(); }
internal void TestDelayedBasicAckNackAfterChannelRecovery(TestBasicConsumer1 cons, ManualResetEventSlim latch) { string q = _model.QueueDeclare(GenerateQueueName(), false, false, false, null).QueueName; int n = 30; _model.BasicQos(0, 1, false); _model.BasicConsume(q, false, cons); AutorecoveringConnection publishingConn = CreateAutorecoveringConnection(); IModel publishingModel = publishingConn.CreateModel(); for (int i = 0; i < n; i++) { publishingModel.BasicPublish("", q, null, _encoding.GetBytes("")); } Wait(latch, TimeSpan.FromSeconds(20)); _model.QueueDelete(q); publishingModel.Close(); publishingConn.Close(); }