Azure webjob;计划执行以及按队列触发 [英] Azure webjob; Scheduled execution as well triggers by queue

查看:95
本文介绍了Azure webjob;计划执行以及按队列触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚是否有可能制作一个Azure webjob并按​​计划每1分钟执行一次,并使其能够被队列触发.我设法将两个要求分开完成,但没有一次完成.

I try to figure out if it's possible to make one Azure webjob and behave it scheduled for say like once per 1 minute and also let it be able to be triggered by a queue. I managed to do both of the requirements separate but not combined in one job.

我知道,为了使它们在队列上触发,我需要使用JobHost和带有捕获触发器的方法的Functions类.仍然会阻塞调度程序,仅处理触发器

I know that in order to make them trigger on a queue I need to use JobHost and a Functions class with methods that catch the trigger. Still this blocks the scheduler and only handles triggers

当我省略JobHost ...好了,那么日程安排就完美了.我很确定我要提出一个矛盾,只需要做两个单独的工作,但是也许你们中的一个面临相同的问题并设法实现这一目标.

When I omit the JobHost... well then the schedule works perfect. I'm pretty sure that I'm asking a contradiction and just need to make two seperate jobs but maybe one of you faced the same and manage to achieve it.

推荐答案

由于您已经在使用SDK,因此我不会在此处使用Azure Scheduler/Scheduled Jobs.您可以使用新的 TimerTrigger .

I wouldn't use Azure Scheduler/Scheduled Jobs here, since you're already using the SDK. You can use the new TimerTrigger.

我可能要做的是有两个功能.第一个功能是使用QueueTrigger的功能,另一个功能是使用v1.1.0中发布的新的TimerTrigger WebJobs.您可以在此处看到类似的示例: https://github.com/christopheranderson/feedbackengine#how-does-it-work

What I'd probably do is have two functions. The first function is the function using QueueTrigger and the other is using the new TimerTrigger WebJobs released in v1.1.0. You can see a sample where I do something similar here: https://github.com/christopheranderson/feedbackengine#how-does-it-work

我有一个计时器,用于轮询RSS提要并丢弃Queue消息,但是我也可以只从其他应用程序中删除Queue消息,或者像在我的场景中一样使用WebHook.

There I have a timer which polls an RSS feed and drops Queue messages, but I can also just drop the Queue messages from another application or, as I did in my scenario, use a WebHook.

计时器触发文档: https://github.com/Azure/azure- webjobs-sdk-extensions#timertrigger

示例:

// Triggers every minute (every time the clock looks like 00:xx:xx)
public static void CronJob([TimerTrigger("0 * * * * *")] TimerInfo timer, [Queue("Foo")] out string message)
{
    Console.WriteLine("Cron job fired!");
    message = "Hello world!";
}

public static void QueueJob([QueueTrigger("Foo")] string message)
{
    Console.WriteLine(message);
}

这篇关于Azure webjob;计划执行以及按队列触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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