Reputation: 5394
The question is about ServiceBusProcessor from Azure.Messaging.ServiceBus v7.1.1 used with .NET 5
When I do this
var processor = client1.CreateProcessor("queueName",
new ServiceBusProcessorOptions { MaxConcurrentCalls = 3 });
processor.ProcessMessageAsync += ProcessMessageAsync;
await processor.StopProcessingAsync();
I assume it would all run in 1 thread unless I explicitly create Task
s in the thread pool in ProcessMessageAsync
?
(Could run 3 concurrent calls if the other 2 calls get blocked by IO and release the thread)
Is this correct?
Upvotes: 0
Views: 948
Reputation: 7780
The processor runs a set of background tasks to receive messages, each working independently. In your example, because MaxConcurrentCalls
is 3, you'll have 3 tasks running concurrently.
Each task will invoke your ProcessMessageAsync
handler, which means that your handler is also being executed concurrently. Unless you're using a shared resource or explicitly synchronizing your handler calls, blocking on one handler invocation will not block the others.
Upvotes: 3