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
WebJob
would exit while process message, you don't have to worry about corrupted data. When theWebJob
access the message to process, it will hide the message in the queue for a certain amount time. If yourWebJob
shut 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
CancellationToken
you can pass to you triggered function and judge the propertyIsCancellationRequired
value , then you could handle theWebJob
would shut down. Here is the sample code aboutCancellationToken
.