Skip to content

Commit

Permalink
Merge pull request #81 from wemogy/feature/configureServiceBusProcess…
Browse files Browse the repository at this point in the history
…orOptions

Added configureServiceBusProcessorOptions support
  • Loading branch information
SebastianKuesters authored Feb 17, 2024
2 parents c11cb05 + e156e13 commit 778edd6
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 778edd6

Please sign in to comment.