运行 hangfire 单线程 "mode"

Running hangfire single threaded "mode"

有什么方法可以将 hangfire 配置为 运行 单线程吗?我希望作业按顺序处理,而不是同时处理。

类似于:

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

这个或 "chain" 作业的能力,以便它们按顺序发生。

类似于:

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

显然应该阅读文档...

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

要配置单线程,请使用 BackgroundJobServerOptions 类型,并指定 workerCount:

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

此外,job chaining似乎是 Hangfire Pro 版本的一个功能。