2

有没有办法将hangfire配置为运行单线程?我希望按顺序处理作业,而不是同时处理。

就像是:

app.UseHangfire(config =>
        {
            config.RunSingleThreaded();
            config.UseServer();
        });

无论是这个还是将工作“链接”在一起的能力,以便它们按顺序发生。

就像是:

BackgroundJob
    .Enqueue(() => taskContainer.PublishBatch(batchId, accountingPeriodId, currentUser, filePath))
    .WithDependentJobId(23); // does not run until this job has finished...
4

1 回答 1

9

Should have read the docs obviously...

http://docs.hangfire.io/en/latest/background-processing/configuring-degree-of-parallelism.html

To configure single thread use the BackgroundJobServerOptions type, and specify workerCount:

var server = new BackgroundJobServer(new BackgroundJobServerOptions
                                         {
                                             WorkerCount = 1
                                         });

Also, it appears job chaining is a feature of Hangfire Pro version.

于 2015-04-22T10:42:45.230 回答