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

标签 c# azure-webjobs azure-queues

我在 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/

相关文章:

Azure WebJob 计划错误 - ETAG

Azure WebJobs 发布错误

c# - Azure函数: how to implement delay of retrying queue message better

c# - RavenDB查询以检查用户名和密码

c# - 如何实现一个类的泛型和非泛型版本?

c# - 为什么我的 Azure WebJob 应用程序中的 TimerTrigger'd 函数未被检测到?

c# - Azure队列在DeleteMessage上抛出异常

Azure函数队列触发器被触发两次,两个实例正在运行?

c# - 为什么在使用 .NET Newtonsoft.Json 组件反序列化一些有效的 json 时,我的 POCO 中的所有集合都是空的

c# - 并发插入数据库