From e156e137a444942ec32170b43b0833acab6f2f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCsters?= Date: Sat, 17 Feb 2024 10:27:35 +0100 Subject: [PATCH] Added configureServiceBusProcessorOptions support --- .../Setup/AzureServiceBusSetupEnvironment.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Setup/AzureServiceBusSetupEnvironment.cs b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Setup/AzureServiceBusSetupEnvironment.cs index ff93b8f..1489fcd 100644 --- a/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Setup/AzureServiceBusSetupEnvironment.cs +++ b/src/extensions/azureServiceBus/Wemogy.CQRS.Extensions.AzureServiceBus/Setup/AzureServiceBusSetupEnvironment.cs @@ -30,17 +30,22 @@ public AzureServiceBusSetupEnvironment(ServiceBusClient serviceBusClient, IServi /// Creates a ServiceBusProcessor and subscribes to messages of type /// public AzureServiceBusSetupEnvironment AddDelayedProcessor( - int maxConcurrentCalls = 1) + int maxConcurrentCalls = 1, + Action? configureServiceBusProcessorOptions = null) where TCommand : ICommandBase { var queueName = GetQueueName(); _serviceCollection.AddHostedService>(_ => { - var serviceBusProcessor = _serviceBusClient.CreateProcessor(queueName, new ServiceBusProcessorOptions() + var serviceBusProcessorOptions = new ServiceBusProcessorOptions() { MaxConcurrentCalls = maxConcurrentCalls - }); + }; + + configureServiceBusProcessorOptions?.Invoke(serviceBusProcessorOptions); + + var serviceBusProcessor = _serviceBusClient.CreateProcessor(queueName, serviceBusProcessorOptions); var processor = new AzureServiceBusCommandProcessor(serviceBusProcessor, _serviceCollection); return processor;