Skip to content

Commit 4e50ada

Browse files
authored
Merge pull request #1156 from rabbitmq/rabbitmq-dotnet-client-1140-6.x
Merge pull request #1148 from rabbitmq/rabbitmq-dotnet-client-1140
2 parents bcf4e59 + 6152045 commit 4e50ada

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

projects/RabbitMQ.Client/client/impl/AutorecoveringModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,19 @@ public void AutomaticallyRecover(AutorecoveringConnection conn, bool recoverCons
441441
newModel.TxSelect();
442442
}
443443

444+
/*
445+
* https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/1140
446+
* If this assignment is not done before recovering consumers, there is a good
447+
* chance that an invalid Model will be used to handle a basic.deliver frame,
448+
* with the resulting basic.ack never getting sent out.
449+
*/
450+
_delegate = newModel;
451+
444452
if (recoverConsumers)
445453
{
446454
_connection.RecoverConsumers(this, newModel);
447455
}
448456

449-
_delegate = newModel;
450457
RunRecoveryEventHandlers();
451458
}
452459

projects/Unit/Fixtures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ internal void StopRabbitMQ()
675675
internal void StartRabbitMQ()
676676
{
677677
ExecRabbitMQCtl("start_app");
678+
ExecRabbitMQCtl("await_startup");
678679
}
679680

680681
//

projects/Unit/TestConnectionRecovery.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public void CleanUp()
7575
}
7676

7777
[Test]
78-
[Ignore("TODO flaky")]
7978
public void TestBasicAckAfterChannelRecovery()
8079
{
8180
var allMessagesSeenLatch = new ManualResetEventSlim(false);
@@ -98,7 +97,6 @@ public void TestBasicAckAfterChannelRecovery()
9897
}
9998

10099
[Test]
101-
[Ignore("TODO flaky")]
102100
public void TestBasicNackAfterChannelRecovery()
103101
{
104102
var allMessagesSeenLatch = new ManualResetEventSlim(false);
@@ -121,7 +119,6 @@ public void TestBasicNackAfterChannelRecovery()
121119
}
122120

123121
[Test]
124-
[Ignore("TODO flaky")]
125122
public void TestBasicRejectAfterChannelRecovery()
126123
{
127124
var allMessagesSeenLatch = new ManualResetEventSlim(false);
@@ -839,23 +836,23 @@ public void TestPublishRpcRightAfterReconnect()
839836
var properties = Model.CreateBasicProperties();
840837
properties.ReplyTo = "amq.rabbitmq.reply-to";
841838

842-
bool done = false;
839+
TimeSpan doneSpan = TimeSpan.FromMilliseconds(100);
840+
var done = new ManualResetEventSlim(false);
843841
var t = new Thread(() =>
844842
{
845843
try
846844
{
847845

848846
CloseAndWaitForRecovery();
849-
Thread.Sleep(100);
850847
}
851848
finally
852849
{
853-
done = true;
850+
done.Set();
854851
}
855852
});
856853
t.Start();
857854

858-
while (!done)
855+
while (!done.IsSet)
859856
{
860857
try
861858
{
@@ -869,9 +866,8 @@ public void TestPublishRpcRightAfterReconnect()
869866
Assert.AreNotEqual(406, a.ShutdownReason.ReplyCode);
870867
}
871868
}
872-
Thread.Sleep(1);
869+
done.Wait(doneSpan);
873870
}
874-
875871
t.Join();
876872
}
877873

0 commit comments

Comments
 (0)