Azure / Azure/Azure-Functions

Unable to limit the maximum number of concurrent service bus messages processed at a time

Open
#2,144 5 comments 0 reactions 1 assignee Claimed by @v-bbalaiagar View on GitHub
bug
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I am using Azure Functions 3.0.13 and referring to the [documentation provided](https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json)

I have one TimerTrigger that runs daily that puts 0...N messages on the service bus that is then processed by a function with a ServiceBusTrigger that consumes said messages.

Using the host.json input provided, however, I can see that all messages are processed at the same time regardless of setting maxConcurrentCalls to 1.

This is causing all functions to run in parallel and resulting in a deadlock on my database.

I can use the decorator `[Singleton(Mode = SingletonMode.Function)]` to run one at a time however this is affecting my throughput and I would rather be able to control how many messages can be processed in parallel at a time.

Am I misinterpreting the documentation or is this a bug?

host.json
```
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
}
},
"functionTimeout": "01:00:00",
"extensions": {
"serviceBus": {
"prefetchCount": 1,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 1,
"maxAutoRenewDuration": "00:05:00"
},
"batchOptions": {
"maxMessageCount": 1,
"operationTimeout": "00:05:00",
"autoComplete": true
}
},
"durableTask": {
"maxConcurrentActivityFunctions": 5,
"maxConcurrentOrchestratorFunctions": 1
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.