Skip to content

Commit c9e36dc

Browse files
Merge pull request #823 from AndrzejKrol/Use_ContinuationTimeout_From_ConnectionFactory
AutorecoveringConnection uses ContinuationTimeout from ConnectionFactory
2 parents d5c90f7 + 35ebb63 commit c9e36dc

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public RecoveryAwareModel CreateNonRecoveringModel()
299299
{
300300
ISession session = _delegate.CreateSession();
301301
var result = new RecoveryAwareModel(session);
302+
result.ContinuationTimeout = _factory.ContinuationTimeout;
302303
result._Private_ChannelOpen("");
303304
return result;
304305
}

projects/Unit/Fixtures.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ internal IConnection CreateNonRecoveringConnection()
165165
return cf.CreateConnection($"UNIT_CONN:{Guid.NewGuid()}");
166166
}
167167

168+
internal IConnection CreateConnectionWithContinuationTimeout(bool automaticRecoveryEnabled, TimeSpan continuationTimeout)
169+
{
170+
var cf = new ConnectionFactory
171+
{
172+
AutomaticRecoveryEnabled = automaticRecoveryEnabled,
173+
ContinuationTimeout = continuationTimeout
174+
};
175+
return cf.CreateConnection($"UNIT_CONN:{Guid.NewGuid()}");
176+
}
177+
168178
//
169179
// Channels
170180
//
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 1.1.
3+
//
4+
// The APL v2.0:
5+
//
6+
//---------------------------------------------------------------------------
7+
// Copyright (c) 2007-2020 VMware, Inc.
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
//---------------------------------------------------------------------------
21+
//
22+
// The MPL v1.1:
23+
//
24+
//---------------------------------------------------------------------------
25+
// The contents of this file are subject to the Mozilla Public License
26+
// Version 1.1 (the "License"); you may not use this file except in
27+
// compliance with the License. You may obtain a copy of the License
28+
// at https://www.mozilla.org/MPL/
29+
//
30+
// Software distributed under the License is distributed on an "AS IS"
31+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
32+
// the License for the specific language governing rights and
33+
// limitations under the License.
34+
//
35+
// The Original Code is RabbitMQ.
36+
//
37+
// The Initial Developer of the Original Code is Pivotal Software, Inc.
38+
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
39+
//---------------------------------------------------------------------------
40+
41+
using System;
42+
using NUnit.Framework;
43+
44+
namespace RabbitMQ.Client.Unit
45+
{
46+
[TestFixture]
47+
internal class TestConnectionFactoryContinuationTimeout : IntegrationFixture
48+
{
49+
[Test]
50+
public void TestConnectionFactoryContinuationTimeoutOnRecoveringConnection()
51+
{
52+
var continuationTimeout = TimeSpan.FromSeconds(777);
53+
using (IConnection c = CreateConnectionWithContinuationTimeout(true, continuationTimeout))
54+
{
55+
Assert.AreEqual(continuationTimeout, c.CreateModel().ContinuationTimeout);
56+
}
57+
}
58+
59+
[Test]
60+
public void TestConnectionFactoryContinuationTimeoutOnNonRecoveringConnection()
61+
{
62+
var continuationTimeout = TimeSpan.FromSeconds(777);
63+
using (IConnection c = CreateConnectionWithContinuationTimeout(false, continuationTimeout))
64+
{
65+
Assert.AreEqual(continuationTimeout, c.CreateModel().ContinuationTimeout);
66+
}
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)