Warm tip: This article is reproduced from serverfault.com, please click

azure servicebus maxConcurrentCalls totally ignored

发布于 2020-10-21 20:53:18

I have thsese in my host.json but every time i run the function it runs in parallel runing much more threads then 1 ( so much as there are messages in queue)

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "prefetchCount": 1,
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1
      }
    }
  }
}

my function

 [FunctionName(nameof(ResourceEventProcessorFunction))]
    public async Task Run([ServiceBusTrigger("%TopicName%", "%SubscriptionName%", Connection = "ServiceBusConnection", IsSessionsEnabled = true)]Message message, IMessageSession messageSession, ILogger log)
Questioner
kosnkov
Viewed
0
kosnkov 2020-11-08 05:11:29

so the problem was that every message had a differnet sessionId. Disabling sessionId on subscription in azure solved this problem.

In details below for bounty :D azure docs doesnt exactly specify how to limit thread number, but I looked a bit dipper.

there is MessageRecievePump and SessionRecievePump one uses MaxConcurrentCalls the other one MaxConcurrentSessions and MaxConcurrentAcceptSessionCalls

be aware of this if you include session in your subscription (MaxConcurrentCalls doesnt work) it works only when session id is the same. when session is differnt try to use MaxConcurrentSessions or MaxConcurrentAcceptSessionCalls but be aware there are no docs about this....