简体   繁体   English

处理由队列触发的 Azure Functions 调用的 Azure Durable Functions 中发生的错误/失败

[英]Handling errors/failures occurred in Azure Durable Functions called by queue-triggered Azure Functions

We have an Azure Storage Queue which triggers an azure function once a payload/message hits the queue.我们有一个 Azure 存储队列,一旦有效负载/消息到达队列,它就会触发一个 azure 函数。 The queue-triggered function invokes another durable function to process the message/payload.队列触发函数调用另一个持久函数来处理消息/有效负载。

Here it is the code snippet:这是代码片段:

        [FunctionName("QueueTriggerFunction")]
        public Task QueueTriggerFunction(
            [QueueTrigger("MyQueue", Connection = "MyStorage")]string item,
            [OrchestrationClient] DurableOrchestrationClient client,
            ILogger log)
            => client.StartNewAsync("Processor", JsonConvert.DeserializeObject<MyObject>(item));

And the durable function looks like the following code sample:持久函数类似于以下代码示例:

[FunctionName("Processor")]
        public async Task ConcurrencyProcessorAsync(
            [OrchestrationTrigger] DurableOrchestrationContext context,
            ILogger log)
        {
            var myObject= context.GetInput<MyObject>();

            if(ObjectProcessor(myObject) == false)
            {
                throw new Exception("Processor failed");
            }
        }

I'd like the payload to end up in the poison messages queue if the exception above is raised upon failing the ObjectProcessor method but it's not happening in reality because the exception does not bublle up through the orchestrator client.如果在ObjectProcessor方法失败时引发上述异常,我希望有效负载最终进入有害消息队列,但实际上并没有发生,因为该异常不会通过协调器客户端冒泡。 Any suggestions on how to make this exception thrown back to the caller function which is a queue-triggered one to make the payload appear in the poison messages queue?关于如何将此异常抛回调用者函数的任何建议,调用者函数是队列触发的,以使有效负载出现在有害消息队列中?

You can't.你不能。

The QueueTriggerFunction just starts the Orchestration . QueueTriggerFunction只是启动Orchestration After that it's life cycle ends.之后它的生命周期结束。

I believe you can directly add your payload to poison queue using either Azure Storage Services REST API or this .Net library我相信您可以使用Azure 存储服务 REST API或这个.Net 库直接将您的有效负载添加到毒药队列

Please note that name of poison queue == $"{queueName}-poison"请注意毒药队列的名称 == $"{queueName}-poison"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM