当前位置: 动力学知识库 > 问答 > 编程问答 >

Hangfire - Recurring job with specified queue name

问题描述:

I have two server, ServerA and ServerB. They share the same hangfire database.

I have two jobs, JobA and JobB.

On ServerA, I use:

RecurringJob.AddOrUpdate(

"JobA",

() => new JobA().Execute(),

this._configuration.Schedule, queue: "A");

On ServerB, I use:

 RecurringJob.AddOrUpdate(

"JobB",

() => new JobB().Execute(),

this._configuration.Schedule, queue: "B");

The problem is that each jobs is "Enqueued" in the "Job" table, they are never executed.

If I remove the queue override in the "AddOrUpdate" method, jobs are executed (obviously without queue configured).

Something missing? How configure recurring jobs with queue configuration?

网友答案:

Code was missing...

ServerA:

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

            this._backgroundJobServer = new BackgroundJobServer(options);

ServerB:

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

            this._backgroundJobServer = new BackgroundJobServer(options);
分享给朋友:
您可能感兴趣的文章:
随机阅读: