function to process only single message at one time

Yang Chowmun 411 Reputation points
2021-07-29T10:55:23.987+00:00

I have written a function that is triggered by service bus.
The function is expected to process one message at one time from service bus.
To perform this, I have added on some service bus configuration on the host.json as shown below.

"extensions": {
"serviceBus": {
"prefetchCount": 1,
"messageHandlerOptions": {
"maxConcurrentCalls": 1}
},
"sessionHandlerOptions": {
"autoComplete": false,
"maxConcurrentSessions": 1
},
"batchOptions": {
"maxMessageCount": 1}
}

Is anyone know that with the above setting, the function will only process a message at once.
Or i still required to add on some other configuration

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,229 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 68,396 Reputation points
    2021-07-30T03:19:42.857+00:00

    @Yang Chowmun The maxConcurrentCalls configuration helps in defining the maximum number of concurrent calls to the callback that the message pump should initiate per scaled instance. By default, the Functions runtime processes multiple messages concurrently.

    Similarly maxConcurrentSessions configuration help with the maximum number of sessions that can be handled concurrently per scaled instance in case of sessions.
    For rest of the configuration as per your requirement you can define in host.json setting. For more details please refer to this.

    If your requirement is that only one message need to be processed at a time per instance then you can use the above configuration.
    But if your requirement is Singleton support for Functions to ensure only one function running at a time then you need to configure this.


1 additional answer

Sort by: Most helpful
  1. Moin Khan 1 Reputation point
    2022-03-31T05:39:20.013+00:00

    Hi @MayankBargali-MSFT

    i have used the same host json and my project also needs to execute one message at a time

    somehow it is executing 2 messages at a time when multiple messages are coming   
    

    Can you please help what mistake i might be doing