[英]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.