question

fool1241-6686 avatar image
0 Votes"
fool1241-6686 asked fool1241-6686 commented

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

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://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#host-json

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

azure-functionsazure-service-bus
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JaliyaUdagedara avatar image
2 Votes"
JaliyaUdagedara answered fool1241-6686 commented

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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

thank you.
I understand that the following settings should be made.
```
Session-disabled Case: messageHandlerOptions.maxConcurrentCalls = 1

Session-enabled Case: sessionHandlerOptions.maxConcurrentSessions = 1
```

0 Votes 0 ·