I'm wondering what if for some reason the WebJob has stopped working
while it was processing a queue trigger.
Firstly, if the WebJob
would exit while process message, you don't have to worry about corrupted data. When the WebJob
access the message to process, it will hide the message in the queue for a certain amount time. If your WebJob
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 property IsCancellationRequired
value , then you could handle the WebJob
would shut down. Here is the sample code about CancellationToken
.