I want to process sessions concurrently. However, within each session, I want to process only one message at a time.
ServiceBusProcessorClient processorClient = new ServiceBusClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.fullyQualifiedNamespace(InsightsServiceSBEndPoint)
.sessionProcessor()
.queueName(SuccesQueue)
.maxConcurrentSessions(5)
.maxConcurrentCalls(5)
With the above setting, the processor processes multiple sessions concurrently as intended. But say if I send 3 messages for session id#1, I see all the 3 messages being processed concurrently. I want these 3 messages to be processed one after the other (otherwise there is no benefit of using sessions)
What am I missing?
There are 2 important processor configurations that impact session based processing.
MaxConcurrentSessions- the maximum number of sessions that can be processed concurrently by a function.MaxConcurrentCallsPerSession- the maximum number of concurrent calls to the function per session. Thus the total number of concurrent calls will be equal to MaxConcurrentSessions X MaxConcurrentCallsPerSession.The
maxConcurrentCallsis not for sessions processing but for non sessions enabled entities. To achieve what you need, the code would be