Azure耐用功能-执行滞后

时间:2019-03-20 05:04:14

标签: c# azure-durable-functions

我看到Azure耐用函数的某些奇怪行为-创建新的业务流程时,它会生成以下代码,其中我修改了其中一行(请参见代码中的注释):

    [FunctionName("TesterOrchestrator")]
    public static async Task<List<string>> RunOrchestrator(
        [OrchestrationTrigger] DurableOrchestrationContext context)
    {
        var outputs = new List<string>();

        // Replace "hello" with the name of your Durable Activity Function.
        outputs.Add(await context.CallActivityAsync<string>("TesterOrchestrator_Hello", "Tokyo"));
        outputs.Add(await context.CallActivityAsync<string>("TesterOrchestrator_Hello", "Seattle"));
        outputs.Add(await context.CallActivityAsync<string>("TesterOrchestrator_Hello", "London"));

        // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
        return outputs;
    }

    [FunctionName("TesterOrchestrator_Hello")]
    public static string SayHello([ActivityTrigger] string name, ILogger log)
    {
        log.LogInformation($"Saying hello to {name}.");
        return $"Hello {name}!";
    }

    [FunctionName("TesterOrchestrator_HttpStart")]
    public static async Task<HttpResponseMessage> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
        [OrchestrationClient]DurableOrchestrationClient starter,
        ILogger log)
    {
        // Function input comes from the request content.
        string instanceId = await starter.StartNewAsync("TesterOrchestrator", null);

        log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

        // this is the line I have changed - I want the code to return the result
        // (if within 10 seconds) and only if it takes longer than that return the URLs for status checking, termination etc
        return await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req, instanceId, TimeSpan.FromSeconds(10), TimeSpan.FromMilliseconds(250));
    }

现在,鉴于代码实际上并没有执行任何操作,它应该几乎立即返回,但是我所看到的(向启动函数发出请求时)是在使用〜之间摇摆不定1秒钟返回“ hello”消息,这需要花费几秒钟(6+),并且在返回带有URL的a 202响应之间(这意味着它花了10秒钟并且放弃了返回响应)。

什么会导致延误?

0 个答案:

没有答案