I have one webjob on azure, with a QueueTrigger. The job is long (More than 30 minutes)
public async static Task ProcessQueueMessageAsync([QueueTrigger(QUEUENAME)] string iJobId)
{
//doing my long job
}
My problem is how delete the message in the queue after triggering. The message becomes invisible until a the timespan (30s by default) comes. Much less of my job duration. So I suppose that I have to delete the message at the beginning of the trigger method.
I find how to do it when you looping with GetMessage()
method instead triggering. But how to do it with trigger, because I don't have the message object to run .DeleteMessage()
?
Answered by Michael Curd on the MSDN Forums, and quoted here:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With