会发生什么"正在进行中的"作业时您部署webjob? [英] What happens to "in-progress" jobs when you deploy a webjob?

查看:200
本文介绍了会发生什么"正在进行中的"作业时您部署webjob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主题说,这一切真的:)说我已经有了一个pretty忙天青连续webjob即从蔚蓝的队列处理:

Subject says it all really :) Say I've got a pretty busy Azure continuous webjob that is processing from an azure Queue:

    public static void ProcessQueue([QueueTrigger("trigger")] Info info)
    { .... }

如果我重新部署webjob,我可以看到,任何当前正在执行的任务似乎被中止(我看到一个从来没有完成状态)。我被释放后或工作重播是永远失去了什么?

If I re-deploy the webjob, I can see that any currently executing job seems to be aborted (I see a "Never Finished" status). Is that job replayed after I release or is it lost forever?

此外,有没有一个很好的方式,以确保没有作业正在运行时,我们部署webjobs,或者是由开发到codeA解决方案的(如被选中每次运行一个配置标志)

Also, is there a nice way to make sure that no jobs are running when we deploy webjobs, or is it up to the developer to code a solution to that (such as a config flag that is checked every run).

感谢

推荐答案

在使用该SDK WebJobs一个WebJob从队列中拿起一个消息,它需要10分钟租约收购它。如果作业过程,同时处理消息去世,租期10分钟后到期,消息返回队列。如果WebJob重启后,将重拾该消息。如果函数成功完成的消息只删除。

When a WebJob that uses the WebJobs SDK picks up a message from a queue, it acquires it with a 10 minutes lease. If the job process dies while processing the message, the lease expires after 10 minutes and the message goes back in the queue. If the WebJob is restarted, it will pick that message again. The message is only deleted if the function completes successfully.

因此​​,如果作业死亡,并立即重启,像重新部署的情况下,可能需要长达10分钟再次回升的消息。此外,正因为如此,它建议任一保存状态自己或使函数幂等的。

Therefore, if the job dies and restarts immediately, like in the case of a redeploy, it might take up to 10 minutes to pick again the message. Also, because of this, it is recommended to either save state yourself or make the function idempotent.

在WebJobs仪表盘,你会看到两个调用了同样的信息。他们中的一个将被标记为永远不会结束因为函数的执行没有完成。

In the WebJobs Dashboard you will see two invocations for the same message. One of them will be marked as Never Finished because the function execution never completed.

不幸的是,没有现成的解决方案,以prevent工作从部署过程中运行。你将不得不建立自己的逻辑,通知(通过一个队列的消息?),一个部署即将开始,然后中止主机。主机中止将等待任何现有的功能停止,而且将prevent新的启动。然而,这是一个非常棘手的情况,如果你有webjob的多个实例,因为只有其中一人将获得通知。

Unfortunately, there is no out of the box solution to prevent jobs from running during deploy. You would have to create your own logic that notifies (through a queue message?) that a deploy is about the start and then aborts the host. The host abort will wait for any existing function to stop and will prevent new ones from starting. However, this is a very tricky situation if you have multiple instances of the webjob because only one of them will get the notification.

这篇关于会发生什么"正在进行中的"作业时您部署webjob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆