Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure WebJob QueueTrigger How DeleteMessage after get it?

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()?

like image 530
Julian50 Avatar asked Jun 18 '15 18:06

Julian50


Video Answer


1 Answers

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.

like image 172
Julian50 Avatar answered Oct 08 '22 14:10

Julian50