How do I get Session-enabled Service Bus Trigger Functions to work in a single thread?

fool1241 81 Reputation points
2021-11-10T15:15:07.257+00:00

Session-disabled Service Bus Trigger Functions
Was set to messageHandlerOptions.maxConcurrentCalls = 1 when operating in a single thread.

If I want Session-enabled Service Bus Trigger Functions to be single-threaded, should I set sessionHandlerOptions.maxConcurrentSessions to 1?

   json  
   {  
       "version": "2.0",  
       "extensions": {  
           "serviceBus": {  
               "prefetchCount": 100,  
               "messageHandlerOptions": {  
                   "autoComplete": true,  
                   "maxConcurrentCalls": 1,  
                   "maxAutoRenewDuration": "00:05:00"  
               },  
               "sessionHandlerOptions": {  
                   "autoComplete": false,  
                   "messageWaitTimeout": "00:00:30",  
                   "maxAutoRenewDuration": "00:55:00",  
                   "maxConcurrentSessions": 1  
               },  
               "batchOptions": {  
                   "maxMessageCount": 1000,  
                   "operationTimeout": "00:01:00",  
                   "autoComplete": true  
               }  
           }  
       }  
   }  

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#host-json

https://learn.microsoft.com/en-us/java/api/com.microsoft.azure.servicebus.sessionhandleroptions?view=azure-java-stable

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
548 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,299 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jaliya Udagedara 2,731 Reputation points MVP
    2021-11-10T20:27:08.153+00:00

    Azure Functions uses ServiceBusSessionProcessor. Sessions are to enforce FIFO processing.

    If you want a function instance to process only one session, you can set MaxConcurrentSessions = 1. That instructs only a single session will be processed by the processor. The default value is 8 meaning 8 sessions will be processed concurrently by the processor.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful