2015-04-23 61 views

回答

9

通過IBackgroundJobClient實例,您可以指定一個隊列。

IBackgroundJobClient hangFireClient = new BackgroundJobClient(); 
EnqueuedState myQueueState = new Hangfire.States.EnqueuedState("myQueue"); 
hangFireClient.Create<SomeClass>(c => c.SomeMethod(), myQueueState); 

請注意,通過這種方式,重試會將作業恢復到默認隊列。你將需要額外的代碼在同一個隊列重試,使用JobFilter

http://discuss.hangfire.io/t/one-queue-for-the-whole-farm-and-one-queue-by-server/490/3

+0

我已經試過了,但它給了我,儘管使用...創建「無法創建inteface的實例」( x => x.Bar(),myQueueState)。有任何想法嗎? – JohanLarsson

+0

可能缺少依賴注入解析器,但我現在猜測你已經解決了你的問題。對不起,沒有早點看到你的問題。 – Xavero

+0

爲我工作。類和方法不能是靜態的,但它工作正常。 –