Skip to content

Commit 601f501

Browse files
committed
* We've come full circle ... restoring @danielmarbach's original changes.
1 parent 7770fd8 commit 601f501

File tree

8 files changed

+11
-67
lines changed

8 files changed

+11
-67
lines changed

projects/RabbitMQ.Client/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,4 +894,4 @@ static RabbitMQ.Client.IChannelExtensions.BasicPublishAsync(this RabbitMQ.Client
894894
RabbitMQ.Client.IChannel.ConfirmSelectAsync(bool trackConfirmations = true, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
895895
const RabbitMQ.Client.Constants.DefaultConsumerDispatchConcurrency = 1 -> ushort
896896
readonly RabbitMQ.Client.ConnectionConfig.ConsumerDispatchConcurrency -> ushort
897-
RabbitMQ.Client.IConnection.CreateChannelAsync(ushort consumerDispatchConcurrency = 1, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IChannel!>!
897+
RabbitMQ.Client.IConnection.CreateChannelAsync(ushort? consumerDispatchConcurrency = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<RabbitMQ.Client.IChannel!>!

projects/RabbitMQ.Client/client/api/IConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ Task CloseAsync(ushort reasonCode, string reasonText, TimeSpan timeout, bool abo
239239
/// will be offloaded to the worker thread pool so it is important to choose the value for the concurrency wisely to avoid thread pool overloading.
240240
/// <see cref="IAsyncBasicConsumer"/> can handle concurrency much more efficiently due to the non-blocking nature of the consumer.
241241
///
242-
/// Defaults to <see cref="Constants.DefaultConsumerDispatchConcurrency"/>.
242+
/// Defaults to <c>null</c>, which will use the value from <see cref="IConnectionFactory.ConsumerDispatchConcurrency"/>
243243
///
244244
/// For concurrency greater than one this removes the guarantee that consumers handle messages in the order they receive them.
245245
/// In addition to that consumers need to be thread/concurrency safe.
246246
/// </param>
247247
/// <param name="cancellationToken">Cancellation token</param>
248-
Task<IChannel> CreateChannelAsync(ushort consumerDispatchConcurrency = Constants.DefaultConsumerDispatchConcurrency,
248+
Task<IChannel> CreateChannelAsync(ushort? consumerDispatchConcurrency = null,
249249
CancellationToken cancellationToken = default);
250250
}
251251
}

projects/RabbitMQ.Client/client/framing/Channel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ namespace RabbitMQ.Client.Framing.Impl
3838
{
3939
internal class Channel : ChannelBase
4040
{
41-
public Channel(ConnectionConfig config, ISession session,
42-
ushort consumerDispatchConcurrency = Constants.DefaultConsumerDispatchConcurrency)
41+
public Channel(ConnectionConfig config, ISession session, ushort? consumerDispatchConcurrency = null)
4342
: base(config, session, consumerDispatchConcurrency)
4443
{
4544
}

projects/RabbitMQ.Client/client/framing/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static class Constants
8787
/// <summary>
8888
/// The default consumer dispatch concurrency. See <see cref="IConnectionFactory.ConsumerDispatchConcurrency"/>
8989
/// to set this value for every channel created on a connection,
90-
/// and <see cref="IConnection.CreateChannelAsync(ushort, System.Threading.CancellationToken)"/>
90+
/// and <see cref="IConnection.CreateChannelAsync(ushort?, System.Threading.CancellationToken)"/>
9191
/// for setting this value for a particular channel.
9292
/// </summary>
9393
public const ushort DefaultConsumerDispatchConcurrency = 1;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
using RabbitMQ.Client.Events;
3838
using RabbitMQ.Client.Exceptions;
3939
using RabbitMQ.Client.Impl;
40-
using RabbitMQ.Util;
4140

4241
namespace RabbitMQ.Client.Framing.Impl
4342
{
@@ -241,11 +240,11 @@ await CloseInnerConnectionAsync()
241240
}
242241
}
243242

244-
public async Task<IChannel> CreateChannelAsync(ushort consumerDispatchConcurrency = Constants.DefaultConsumerDispatchConcurrency,
243+
public async Task<IChannel> CreateChannelAsync(ushort? consumerDispatchConcurrency = null,
245244
CancellationToken cancellationToken = default)
246245
{
247246
EnsureIsOpen();
248-
ushort cdc = Misc.DetermineConsumerDispatchConcurrency(_config, consumerDispatchConcurrency);
247+
ushort cdc = consumerDispatchConcurrency.GetValueOrDefault(_config.ConsumerDispatchConcurrency);
249248
RecoveryAwareChannel recoveryAwareChannel = await CreateNonRecoveringChannelAsync(cdc, cancellationToken)
250249
.ConfigureAwait(false);
251250
AutorecoveringChannel channel = new AutorecoveringChannel(this, recoveryAwareChannel, cdc);

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
using RabbitMQ.Client.Events;
4646
using RabbitMQ.Client.Exceptions;
4747
using RabbitMQ.Client.Framing.Impl;
48-
using RabbitMQ.Util;
4948

5049
namespace RabbitMQ.Client.Impl
5150
{
@@ -75,10 +74,11 @@ internal abstract class ChannelBase : IChannel, IRecoverable
7574
internal readonly IConsumerDispatcher ConsumerDispatcher;
7675

7776
protected ChannelBase(ConnectionConfig config, ISession session,
78-
ushort consumerDispatchConcurrency = Constants.DefaultConsumerDispatchConcurrency)
77+
ushort? perChannelConsumerDispatchConcurrency = null)
7978
{
8079
ContinuationTimeout = config.ContinuationTimeout;
81-
ConsumerDispatcher = BuildConsumerDispatcher(config, consumerDispatchConcurrency);
80+
ConsumerDispatcher = new AsyncConsumerDispatcher(this,
81+
perChannelConsumerDispatchConcurrency.GetValueOrDefault(config.ConsumerDispatchConcurrency));
8282
Action<Exception, string> onException = (exception, context) =>
8383
OnCallbackException(CallbackExceptionEventArgs.Build(exception, context));
8484
_basicAcksWrapper = new EventingWrapper<BasicAckEventArgs>("OnBasicAck", onException);
@@ -94,12 +94,6 @@ protected ChannelBase(ConnectionConfig config, ISession session,
9494
Session = session;
9595
}
9696

97-
private IConsumerDispatcher BuildConsumerDispatcher(ConnectionConfig config, ushort perChannelConsumerDispatchConcurrency)
98-
{
99-
ushort cdc = Misc.DetermineConsumerDispatchConcurrency(config, perChannelConsumerDispatchConcurrency);
100-
return new AsyncConsumerDispatcher(this, cdc);
101-
}
102-
10397
internal TimeSpan HandshakeContinuationTimeout { get; set; } = TimeSpan.FromSeconds(10);
10498
public TimeSpan ContinuationTimeout { get; set; }
10599

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ await CloseAsync(ea, true,
253253
}
254254
}
255255

256-
public Task<IChannel> CreateChannelAsync(ushort consumerDispatchConcurrency = Constants.DefaultConsumerDispatchConcurrency,
256+
public Task<IChannel> CreateChannelAsync(ushort? consumerDispatchConcurrency = null,
257257
CancellationToken cancellationToken = default)
258258
{
259259
EnsureIsOpen();

projects/RabbitMQ.Client/util/Misc.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)