简体   繁体   English

使用服务总线队列中的批量消息而不是为每条消息触发它的方法

[英]Way to consume bulk messages from Service Bus Queue instead of triggering it for each message

We have a Service Bus Queue;我们有一个服务总线队列; we are thinking to handle messages through Service Bus Queue Trigger in the Azure Function. But we want to consume bulk messages (in a loop) instead of re-triggering Function App for each message.我们正在考虑通过 Azure Function 中的 Service Bus Queue Trigger 来处理消息。但是我们想要消费批量消息(在循环中)而不是为每条消息重新触发 Function App。 What should be the way to achieve this and by using which handler.实现此目的的方法应该是什么以及使用哪个处理程序。 Should Azure Function be only used or we can host an App Service for consuming the same.应该只使用 Azure Function 还是我们可以托管一个应用服务来使用它们。

You should use batches.你应该使用批处理。 Simply declare the variable as an array.只需将变量声明为数组即可。

public static class ProcessOrders
{
    [FunctionName("ProcessOrders")]
    public static void Run(
        [ServiceBusTrigger("orders", Connection = "ServiceBusConnection")]
        Message[] orders, // <-- array
        ILogger log)
    {
        log.LogInformation($"Number of orders: {orders.Length}");
    }
}

You can further configure batch size and such using the host.json file.您可以使用host.json文件进一步配置批量大小等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据消息属性筛选 Azure 服务总线队列消息? - how do I filter Azure Service Bus Queue messages based on a message property? Azure 服务总线 - 使用 HTTP 调用将消息从订阅复制到队列 - Azure service bus - Copying messages from subscription to a queue using HTTP call 如何使用 spring 引导 java 应用程序从服务总线队列中持续拉取消息 - How to continuously pull messages from service bus queue by using spring boot java application 无法使用托管身份将消息从 Azure API 发布到 Azure 服务总线队列 - Unable to post message to Azure Service Bus Queue from Azure API using Managed Identity 如何在 ASP.NET MVC web 应用程序的 View.cshtml 中从 Azure 服务总线(队列)获取消息 - How to get messages from Azure Service Bus (Queue) in View.cshtml in ASP.NET MVC web app 从 Azure function 向服务总线主题发送批处理消息 - Send batch messages to Service Bus topic from Azure function 使用 Twilio 消息服务发送批量消息时请求过多 - Too Many Requests in sending Bulk Messages using Twilio Message Service 如何使用 MassTransit 将消息发送到 Azure 服务总线中的死信队列? - How to send messages to the dead letter queue in Azure Service Bus using MassTransit? 逻辑应用程序中的服务总线队列连接器未将消息设置为在导致重复的第一个重复间隔内完成 - Service bus queue connector in Logic app is not setting message to complete in first recurrence interval which is causing duplicates 类型错误:为“消息”提供的值必须是类型:服务总线队列中的 ServiceBusMessage Azure - TypeError: Provided value for 'message' must be of type: ServiceBusMessage in a Service Bus Queue Azure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM