Paul
Paul

Reputation: 3293

Force Azure Function using Service Bus Queues to only process one mesage at a time

I have followed the instructions in the link here to try to get an Azure function to process messages in a queue 1 by 1

I am using Azure Service Bus Queues

I deliberately added a delay into the function to slow it down, but I can see that a queue of 250 messages is processed very quickly, despite me adding a delay of a second into the function

Has anyone had issues with trying to do this?

I have this in my host.json

 "queues": {
      "batchSize": 1,
      "newBatchThreshold": 0,
      "maxPollingInterval": "00:00:30",
      "visibilityTimeout": "00:01:00",
      "maxDequeueCount": 3
    }

Paul

Upvotes: 0

Views: 891

Answers (2)

James Law
James Law

Reputation: 6733

For anybody looking to configure this locally for debugging purposes, you can add the following to the Values section in local.settings.json:

"AzureFunctionsJobHost__extensions__serviceBus__maxConcurrentCalls": 1,
"AzureFunctionsJobHost__extensions__serviceBus__maxConcurrentSessions": 1,

Sic. https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#override-hostjson-values

Upvotes: 0

Sean Feldman
Sean Feldman

Reputation: 26057

The link you're referring to is about Azure Storage Queues. For Azure Service Bus, there are several configuration settings you should check, such as maxConcurrentCalls (16 by default) and maxConcurrentSessions if you're using sessions. More information in the official documentation here.

Upvotes: 2

Related Questions