我有一个Azure函数,其输入绑定到事件中心.
I have an Azure Function with an input binding to an Event Hub.
public static async Task Run(TraceWriter log, string eventHubMessage)该功能被触发时,默认情况下每次执行会收到多少条消息?
When the function is triggered, how many messages does it receive per execution by default?
是1次执行= 1条消息吗?
Is it 1 execution = 1 message?
我已阅读文档并了解您可以在函数的host.json文件中设置以下属性:
I have read the documentation and understand you can set these properties in the function's host.json file:
"eventHub": { // The maximum event count received per receive loop. The default is 64. "maxBatchSize": 64, // The default PrefetchCount that will be used by the underlying EventProcessorHost. "prefetchCount": 256 }maxBatchSize是否意味着我将在1次执行中收到64条消息?
Does maxBatchSize mean I will receive 64 messages in 1 execution?
推荐答案@Mikhail是正确的.我只想添加以下内容:
@Mikhail is correct. I'd just like to add the following:
如果您需要每次执行都要分批处理,请更改以下内容:
If you need each execution to process in batches, change the following:
a.在function.json中,添加属性"cardinality":"many",如下所示:此处.
a. In function.json, add the property "cardinality":"many" as shown here.
b.在run.csx中,修改功能签名并循环处理消息,例如
b. In run.csx, modify Function signature and process messages in a loop, e.g.,
public static async Task Run(TraceWriter log, string[] eventHubMessages) { foreach(string message in eventHubMessages) { // process messages } }
public static async Task Run(TraceWriter log, string[] eventHubMessages) { foreach(string message in eventHubMessages) { // process messages } }
通过在问题中指定的host.json配置,您可以尝试使用正确的批处理大小和预取缓冲区来满足工作流程的需求.
The host.json configuration you specified in the question allows you to experiment with the correct batch size and prefetch buffer to meet the needs of your workflow.
其他评论:
更多推荐
Azure功能的事件中心输入绑定
发布评论