Reputation: 105
I have an azure service bus queue set up. Within the host.json file I have maxConcurrentCalls set to 1 however when i debug the app locally there are 8-10 worker threads running and its making the app impossible to debug. How do i have only 1 thread running when i debug my app locally?
Initially my host.json was empty and i found the below code that was supposed to have in order to have only 1 thread execution see https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#host-json
{
"version": "2.0",
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": false,
"maxConcurrentCalls": 1,
"maxAutoRenewDuration": "00:55:00"
}
}
}
}
I added the host.json settings to my local.json settings to no avail, i still get 10 worker threads starting up on launch. I also attempted to make the function call a singleton see Make Azure Function run sequential on ServiceBusTrigger - maxConcurrentCalls not working however, this just locked up the function completely and didnt solve any issues at all.
[FunctionName("ReadFromXCagoIssueQueueAndRetrieveFiles")]
public static void Run([ServiceBusTrigger(QueueName, AccessRights.Manage, Connection = "SBConnection")]BrokeredMessage myQueueItem, TextWriter log)
{
log.WriteLine($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
var propIssueId = myQueueItem.Properties["IssueId"].ToString();
var issueId = int.Parse(propIssueId);
log.WriteLine($"begin grab files for issue: {issueId}");
retrieveIssueEPub(issueId);
}
The execution of retrieveIssueEPub is performed over several worker threads which means that the message ends up in deadletter queue after 1 run of the function due to it splitting the same message across all the threads and not the 1 thread that i expect due to the max concurrent calls. am i missing something? Is there a difference between concurrently pulling out 1 message at a time and executing the function over several threads?
Upvotes: 1
Views: 2058
Reputation: 105
A colleague of mine has found the error. the application is only firing one thread at a time. However on azure itself the lock duration was set to 30 seconds. This means that the app would start new a new thread after 30 seconds etc because the message becomes unlocked. Extending the lock has solved the issue.
Upvotes: 2