gpt4 book ai didi

c# - Azure服务总线: Process 1 message at a time

转载 作者:行者123 更新时间:2023-12-02 07:35:54 25 4
gpt4 key购买 nike

现在,我们使用 Azure 服务总线来触发我们的函数应用。传入消息的速率非常高,但我们希望一次仅触发函数应用程序一条消息(按照我们自己的节奏进行处理,而不是处理太多请求错误)。如何配置服务总线一次只向接收者发送一条消息?这是我们的基本功能应用代码:

    [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}");
}

最佳答案

您不必将服务总线设置为一次发送一条消息,而是将函数应用设置为一次处理一条服务总线消息。转到函数应用的 host.json,然后添加以下内容:

"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"maxConcurrentCalls": 1
}
}
}

关于c# - Azure服务总线: Process 1 message at a time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73901181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com