问题
I have a bunch of webjob queue handling functions:
public static void ProcessSomething(
[QueueTrigger("testrequest")] TestThing thing,
TextWriter logger,
CancellationToken token)
I'm confused about graceful shutdown. So - when you shutdown the webjob (or re-deploy to it), it allows currently processing webjob to run and to complete - by default your Queue handler has 5 seconds to complete. You can pass a CancellationToken
into the method to check for a cancellation request if it's likely that your webjob will take longer, as described in the 'Graceful Shutdown' section of this article.
Ok, but what's weird is that I've found that when Queue handler is running during a shutdown, then the token has it's IsCancellationRequested
set, but even if the function completes within, say a second, then that queue item is marked as "Never Finished", and in 10 mins (after the leasetime for that queue item expires), it comes back on the queue.
Is that by design? Can I change that behavior? If for example your queue handler was sending an email, and it was firing during a shutdown, then it will send the email, then be marked as never finished, then send the email again 10 mins later.
Help!
来源:https://stackoverflow.com/questions/29164414/azure-webjob-graceful-shutdown-of-a-queue-handling-function