I have a continuous Azure WebJob, that is set to 'Always On'. This WebJob is supposed to handle new messages being added to a storage queue.
I'm wondering what if for some reason the WebJob has stopped working while it was processing a queue trigger. This way I will lose the message from the queue, and it won't go to poison queue.
How can I workaround this?
Firstly, if the
WebJobwould exit while process message, you don't have to worry about corrupted data. When theWebJobaccess the message to process, it will hide the message in the queue for a certain amount time. If yourWebJobshut down while process the message, the message will be available again after the time, and it will be re-grabbed and ran against the updated code.About the details, you could refer to this answer.As for your requirement about being notified the job is shutting down. You could use Graceful Shutdown and listen to
CancellationTokenyou can pass to you triggered function and judge the propertyIsCancellationRequiredvalue , then you could handle theWebJobwould shut down. Here is the sample code aboutCancellationToken.