From 15f575d39a0617f767d5c010ad956f9ae6f5a87e Mon Sep 17 00:00:00 2001 From: Thomas Sarmis Date: Tue, 16 Jan 2024 12:50:58 +0200 Subject: [PATCH] add PublishingChannelsPoolSize option --- .../DefaultRabbitMQStreamBus.cs | 5 +++++ src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bus/EasyCaching.Bus.RabbitMQStream/DefaultRabbitMQStreamBus.cs b/bus/EasyCaching.Bus.RabbitMQStream/DefaultRabbitMQStreamBus.cs index ac602cdb..f8d6fe74 100644 --- a/bus/EasyCaching.Bus.RabbitMQStream/DefaultRabbitMQStreamBus.cs +++ b/bus/EasyCaching.Bus.RabbitMQStream/DefaultRabbitMQStreamBus.cs @@ -97,6 +97,11 @@ IPooledObjectPolicy objectPolicy }; var provider = new DefaultObjectPoolProvider(); + + if (_options.PublishingChannelsPoolSize.HasValue) + { + provider.MaximumRetained = _options.PublishingChannelsPoolSize.Value; + } _pubChannelPool = provider.Create(objectPolicy); diff --git a/src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs b/src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs index eec55588..9dc40512 100644 --- a/src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs +++ b/src/EasyCaching.Core/Configurations/BaseRabbitMQOptions.cs @@ -56,5 +56,10 @@ public class BaseRabbitMQOptions /// Gets or sets the client-provided name for the rabbit connection. Default null (handled by rabbit client) /// public string ClientProvidedName { get; set; } + + /// + /// Sets the Pool size for the publishing channels, if null the default is used (default = cpu core count x 2) + /// + public int? PublishingChannelsPoolSize { get; set; } = null; } }