簡體   English   中英

帶有定時器觸發器的 Web 作業

[英]Web jobs with Timer trigger

我有一個 web 作業,它監聽兩個不同的隊列,而不是在 Functions.cs 中編寫我的代碼(我繼承的那個)看起來像這樣。

 UnityContainer container = RegisterContainers();      
        var config = new JobHostConfiguration
        {
            JobActivator = new UnityResolver(container)
        };           
        var host = new JobHost(config);
        ScheduledQueueListener schedulerQueueListener = container.Resolve<ScheduledQueueListener>();
        Thread schedulerQueueThread = new Thread(schedulerQueueListener.Listen);
        schedulerQueueThread.Start();
        Thread genericQueueThread = new Thread(schedulerQueueListener.GenericQueueListen);
        genericQueueThread.Start();
        host.RunAndBlock();
    }

現在來解決我的問題。 I was hoping to create a timertrigger in Function.cs as mentioned here Timer Trigger which comes under nuget of Microsoft.Azure.WebJobs.Extensions and it breaks the current code as after the Nuget installation JoHostConfiguration is no longer valid.Is there anything that I可以在 webjob 中執行,而不是添加 azure 調度程序 / az function 將消息推送到已經偵聽的隊列

Azure WebJob 庫從 1.x/2.x 到 3.x 發生了顯着變化。 我猜你什么時候安裝了 Microsoft.Azure.WebJobs.Extensions Nuget package - 你選擇了最新版本的 3.x,它也會升級你的 otherJob 包。 在 3.x 中,JobHostConfiguration 已被替換。

If you revert back to your working code and then install the latest 2.x version of the Microsoft.Azure.WebJobs.Extensions Nuget package, you should be able to use the TimerTrigger attribute without breaking your JobHostConfiguration code.

更多信息在這里 - https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#webjobs-host

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM