diff --git a/projects/RabbitMQ.Client/CreateChannelOptions.cs b/projects/RabbitMQ.Client/CreateChannelOptions.cs index 63bb50a7d..add4bd952 100644 --- a/projects/RabbitMQ.Client/CreateChannelOptions.cs +++ b/projects/RabbitMQ.Client/CreateChannelOptions.cs @@ -103,10 +103,23 @@ internal CreateChannelOptions(ConnectionConfig connectionConfig) _connectionConfigContinuationTimeout = connectionConfig.ContinuationTimeout; } - internal void WithConnectionConfig(ConnectionConfig connectionConfig) + private void WithConnectionConfig(ConnectionConfig connectionConfig) { _connectionConfigConsumerDispatchConcurrency = connectionConfig.ConsumerDispatchConcurrency; _connectionConfigContinuationTimeout = connectionConfig.ContinuationTimeout; } + + internal static CreateChannelOptions CreateOrUpdate(CreateChannelOptions? createChannelOptions, ConnectionConfig config) + { + if (createChannelOptions is not null) + { + createChannelOptions.WithConnectionConfig(config); + return createChannelOptions; + } + else + { + return new CreateChannelOptions(config); + } + } } } diff --git a/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs b/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs index 9579d1e87..f38de44a1 100644 --- a/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs +++ b/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs @@ -256,15 +256,7 @@ public async Task CreateChannelAsync(CreateChannelOptions? createChann { EnsureIsOpen(); - if (createChannelOptions is null) - { - createChannelOptions = new CreateChannelOptions(_config); - } - else - { - createChannelOptions.WithConnectionConfig(_config); - } - + createChannelOptions = CreateChannelOptions.CreateOrUpdate(createChannelOptions, _config); RecoveryAwareChannel recoveryAwareChannel = await CreateNonRecoveringChannelAsync(createChannelOptions, cancellationToken) .ConfigureAwait(false); diff --git a/projects/RabbitMQ.Client/Impl/Connection.cs b/projects/RabbitMQ.Client/Impl/Connection.cs index 796ddc901..af26bb7ac 100644 --- a/projects/RabbitMQ.Client/Impl/Connection.cs +++ b/projects/RabbitMQ.Client/Impl/Connection.cs @@ -268,15 +268,7 @@ public Task CreateChannelAsync(CreateChannelOptions? createChannelOpti { EnsureIsOpen(); - if (createChannelOptions is null) - { - createChannelOptions = new CreateChannelOptions(_config); - } - else - { - createChannelOptions.WithConnectionConfig(_config); - } - + createChannelOptions = CreateChannelOptions.CreateOrUpdate(createChannelOptions, _config); ISession session = CreateSession(); return Channel.CreateAndOpenAsync(createChannelOptions, session, cancellationToken); }