0

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?

Akram Qalalwa
  • 103
  • 11
  • 1
    Did you check the logs? Maybe an unhandled exception occured? – Peter Bons Nov 25 '18 at 16:11
  • 1
    What's the WebJob status in the Kudu?And did the WebJob work properly at first?Please give more details and i will help you. – George Chen Nov 26 '18 at 01:53
  • Regarding exceptions, I know and already verified that messages caused exceptions while processing will be moved to the Poison queue. – Akram Qalalwa Nov 26 '18 at 08:05
  • What I'm targeting in my question, is that what if I turned off the host App Service while the WebJob was processing a queue message. What will happen to the message then? I'm sure that it won't be moved to the Poison queue, and verified this. But now I can't find my message neither in the original queue, nor in the poison. And it didn't even be processed to the end of my flow due to the job shutdown. Is there anyway I can be notified that my job is shutting down so for example I can return back my message to its' original queue? – Akram Qalalwa Nov 26 '18 at 08:06

1 Answers1

1

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.

George Chen
  • 13,703
  • 2
  • 11
  • 26