Azure webjob - graceful shutdown of a queue handling function

浪尽此生 提交于 2019-12-21 09:37:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!