gpt4 book ai didi

c# - Azure WebJob QueueTrigger 得到DeleteMessage后怎么办?

转载 作者:太空狗 更新时间:2023-10-29 21:38:55 25 4
gpt4 key购买 nike

我在 Azure 上有一个 Web 作业,带有 QueueTrigger。作业时间长(超过30分钟)

public async static Task ProcessQueueMessageAsync([QueueTrigger(QUEUENAME)] string iJobId)
{
//doing my long job
}

我的问题是触发后如何删除队列中的消息。在时间跨度(默认为 30 秒)到来之前,消息变得不可见。我的工作时间要少得多。所以我想我必须在触发方法的开头删除消息。当您使用 GetMessage() 方法循环而不是触发时,我发现了如何做到这一点。但是如何使用触发器来完成它,因为我没有要运行的消息对象 .DeleteMessage()

最佳答案

Answered by Michael Curd on the MSDN Forums , 并在此处引用:

The SDK should already handle that. As you stated, the message will be leased (or become invisible) for 30 seconds by default. If the job takes longer than that, then the lease will be renewed. The message will not become available to another instance of the function unless the host crashes or the function throws an exception. When the function completes successfully, the message is deleted by the SDK. So you shouldn't need to write any special code for this scenario.

关于c# - Azure WebJob QueueTrigger 得到DeleteMessage后怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30922980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com