2016-09-13 2 views
0

서버 A와 B가 두 개 있습니다. 같은 hangfire 데이터베이스를 공유합니다. 저는 JobA와 JobB의 두 가지 직업이 있습니다. ServerA가에Hangfire - 지정된 큐 이름을 사용하는 되풀이 작업

, 내가 사용 :

서버 B에
RecurringJob.AddOrUpdate(
      "JobA", 
      () => new JobA().Execute(), 
      this._configuration.Schedule, queue: "A"); 

, 내가 사용 :

RecurringJob.AddOrUpdate(
      "JobB", 
      () => new JobB().Execute(), 
      this._configuration.Schedule, queue: "B"); 

문제는 각각의 작업이 "작업"테이블에서 "대기열에 포함"입니다, 그들은 결코 실행.

"AddOrUpdate"메서드에서 큐 재정의를 제거하면 작업이 실행됩니다 (큐가 구성되지 않은 것 같습니다).

뭔가가 누락 되었습니까? 대기열 구성으로 되풀이 작업을 구성하는 방법 코드가 누락 된

답변

1

...

ServerA가 :

var options = new BackgroundJobServerOptions 
      { 
       Queues = new[] { "A" } 
      }; 

      this._backgroundJobServer = new BackgroundJobServer(options); 

서버 B :

var options = new BackgroundJobServerOptions 
      { 
       Queues = new[] { "B" } 
      }; 

      this._backgroundJobServer = new BackgroundJobServer(options); 
+0

내가 사용을 hangfire 1.5.6. 비슷한 문제가 있습니다. 해결책을 찾았습니까? –

1

솔루션 - 유사한 문제를 가진 사람 도움이 될 수 있습니다 :

app.UseHangfireServer(new BackgroundJobServerOptions 
{ 
    // queue name must be in lowercase 
    Queues = new[] { "qname" } //This will setup the server to only process qname queues 
}); 

RecurringJob.AddOrUpdate(
    () => new JobB().Execute(), 
    Cron.Hourly(5), 
    null, 
    "qname");