我有一个带有QueueTrigger的Azure耐用功能。在内部,我有一些Azure函数与子编排一起被调用。这是代码
var processKatartItem = context.GetInput<KatartItem>();
if (!processKatartItem.ProcessLeadTime && !processKatartItem.ProcessPrice && !processKatartItem.ProcessStock)
{
await context.CallActivityWithRetryAsync("LLGFeedPreProductMessageProcessor", new RetryOptions(TimeSpan.FromSeconds(1), 5), processKatartItem);
}
var tasks = new Task[processKatartItem.vardatas.Count];
for (var i = 0; i < processKatartItem.vardatas.Count; i++)
{
tasks[i] = context.CallSubOrchestratorWithRetryAsync("LLGFeedProductOrchestrator", new RetryOptions(TimeSpan.FromSeconds(1), 5), new ProductProcessingModel
{
ProcessKatartItem = processKatartItem,
ProcessVardata = processKatartItem.vardatas[i]
});
}
await Task.WhenAll(tasks);
await context.CallActivityWithRetryAsync("LLGFeedFinalizeMessage", new RetryOptions(TimeSpan.FromSeconds(1), 5), processKatartItem);
这是SubOrchestrator的代码
var processModel = context.GetInput<ProductProcessingModel>();
await context.CallActivityWithRetryAsync("LLGFeedProductSpecificationProcessor", new RetryOptions(TimeSpan.FromSeconds(1), 5), processModel);
await context.CallActivityWithRetryAsync("LLGFeedProductMessageProcessor", new RetryOptions(TimeSpan.FromSeconds(1), 5), processModel);
await context.CallActivityWithRetryAsync("LLGFeedProductMappingProcessor", new RetryOptions(TimeSpan.FromSeconds(1), 5), processModel);
await context.CallActivityWithRetryAsync("LLGFeedProductPriceProcessor", new RetryOptions(TimeSpan.FromSeconds(1), 5), processModel);
这种结构的方式是,我们将消息及其子输入处理到数据库中,然后运行MessageFinalization,该函数通过在WebSite上调用Api将消息/产品索引到Elastic Search中。我们将大量消息排队,然后对其进行处理。
我遇到的问题是,耐用功能执行前几个Azure函数,然后等待最后几个。 这是WebJobs仪表板的屏幕截图
因此,您可以看到许多消息已被处理,但LLGFeedFinalizeMessage的1个实例尚未执行。有什么办法可以确保我的整个管道得到执行,而不是先执行前几个功能,然后再执行所有功能。甚至FIFO。那就是让协调器在启动新实例之前等待并完成其所有功能。
Host.json
{
"version": "2.0",
"extensions": {
"durableTask": {
"HubName": "LLGFeedTaskHub",
"ControlQueueBatchSize": 8,
"PartitionCount": 2,
"MaxConcurrentActivityFunctions": 10,
"MaxConcurrentOrchestratorFunctions": 2,
"AzureStorageConnectionStringName": "AzureWebJobsStorage"
},
"queues": {
"batchSize": 10,
"newBatchThreshold": 5
}
},
"functionTimeout": "00:10:00"
}