Right now, we use Azure Service Bus to trigger our function app. The rate of incoming messages is very high, but we want to trigger the function app only one message at a time (to process at our own pace rather than dealing with too many requests error). How to configure the service bus to only send one message at a time to the receiver? Here's our basic function app code:
[FunctionName("ServiceBusListener")]
public void Run([ServiceBusTrigger("myqueue", Connection = "MyConnection")]string queueContent, ILogger log)
{
_myService.ProcessMessage(queueContent);
log.LogInformation($"C# ServiceBus queue trigger function processed message: {queueContent}");
}
You don't set the service bus to send a message one at a time, rather you set your function app to process service bus messages one at a time. Go to the host.json
of your function app, then add the following:
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}