我有一个Azure业务流程,其中触发业务流程的编排客户端抛出了一个超时异常。
业务流程客户端函数只做两件事,启动两个编排,等待每个流程,正如大多数示例代码所建议的那样。
await orchestrationClient.StartNewAsync("TableOrchestrator", updates);
await orchestrationClient.StartNewAsync("ClientOrchestrator", clientExport);然而,正如我所理解的,编排客户端并不像编排函数那样是一个特殊的函数,因此它只能运行10分钟。显然,我的两个管弦乐的综合运行时间很有可能超过10分钟。
问题:
Update提供了一个完整的示例,说明了我的代码所做的工作,以及运行时,如下所示。
如果后面有编写的代码,那么启动业务流程将等待它,但如果编制是最后一条语句,则不会!
更新问题:
。
public static class testOrchestration
{
[FunctionName("Start")]
public static async Task Start([TimerTrigger("0 */30 * * * *", RunOnStartup = true, UseMonitor = false)]TimerInfo myStartTimer, [OrchestrationClient] DurableOrchestrationClient orchestrationClient, ILogger log)
{
var startTime = DateTime.Now;
log.LogInformation(new EventId(0, "Startup"), "Starting Orchestror 1 ***");
await orchestrationClient.StartNewAsync("Orchestrator", "ONE");
log.LogInformation($"Elapsed time, await ONE: {DateTime.Now - startTime}");
await Task.Delay(5000);
log.LogInformation($"Elapsed time, await Delay: {DateTime.Now - startTime}");
log.LogInformation(new EventId(0, "Startup"), "Starting Orchestror 2 ***");
await orchestrationClient.StartNewAsync("Orchestrator", "TWO");
log.LogInformation($"Elapsed time, await TWO: {DateTime.Now - startTime}");
}
[FunctionName("Orchestrator")]
public static async Task<string> TestOrchestrator([OrchestrationTrigger] DurableOrchestrationContextBase context, ILogger log)
{
var input = context.GetInput<string>();
log.LogInformation($"Running {input}");
await Task.Delay(5000);
return $"Done {input}";
}
}运行此操作将给出以下输出:
Starting Orchestror 1 ***
Elapsed time, await ONE: 00:00:08.5445755
Running ONE
Elapsed time, await Delay: 00:00:13.5541264
Starting Orchestror 2 ***
Elapsed time, await TWO: 00:00:13.6211995
Running TWO发布于 2020-02-27 09:16:52
StartNewAsync()只是安排了要启动的编排器(立即)。等待这些调用并不意味着您的初始函数将真正等待协调器运行-甚至实际开始和完成它的工作。
编排客户端绑定上的StartNewAsync (.NET)或startNew (JavaScript)方法将启动一个新实例。在内部,此方法将消息排队到控制队列中,然后控制队列将触发使用编排触发器绑定的指定名称的函数的开始。 此异步操作在业务流程成功调度时完成,
此异步操作在成功调度业务流程时完成。
所以是的:你应该等待这些电话(也可以像米格尔建议的那样并行进行)。但它不会超过几毫秒。
发布于 2020-02-27 03:51:19
如果它们不相互依赖,则可以使用以下方法并行运行它们:
var t1 = orchestrationClient.StartNewAsync("TableOrchestrator", updates);
var t2 = orchestrationClient.StartNewAsync("ClientOrchestrator", clientExport);
await Task.WhenAll(t1, t2);https://stackoverflow.com/questions/60425865
复制相似问题