Skip to content

Commit

Permalink
Added configureServiceBusProcessorOptions support
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianKuesters committed Feb 17, 2024
1 parent c11cb05 commit e156e13
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ public AzureServiceBusSetupEnvironment(ServiceBusClient serviceBusClient, IServi
/// Creates a ServiceBusProcessor and subscribes to messages of type <typeparamref name="TCommand"/>
/// </summary>
public AzureServiceBusSetupEnvironment AddDelayedProcessor<TCommand>(
int maxConcurrentCalls = 1)
int maxConcurrentCalls = 1,
Action<ServiceBusProcessorOptions>? configureServiceBusProcessorOptions = null)
where TCommand : ICommandBase
{
var queueName = GetQueueName<TCommand>();

_serviceCollection.AddHostedService<IDelayedCommandProcessorHostedService<TCommand>>(_ =>
{
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<TCommand>(serviceBusProcessor, _serviceCollection);

return processor;
Expand Down

0 comments on commit e156e13

Please sign in to comment.