【问题标题】:Hangfire - Recurring job with specified queue nameHangfire - 具有指定队列名称的重复作业
【发布时间】:2016-09-13 11:49:43
【问题描述】:

我有两台服务器,ServerA 和 ServerB。它们共享相同的hangfire 数据库。 我有两个工作,JobA 和 JobB。

在 ServerA 上,我使用:

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

在 ServerB 上,我使用:

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

问题是每个作业都在“作业”表中“入队”,它们永远不会被执行。

如果我在“AddOrUpdate”方法中删除队列覆盖,作业将被执行(显然没有配置队列)。

缺少什么?如何使用队列配置配置循环作业?

【问题讨论】:

    标签: hangfire


    【解决方案1】:

    代码丢失...

    服务器A:

    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);
    

    【讨论】:

    • 我使用的是hangfire 1.5.6。我有一个类似的问题 - 你找到解决方案了吗?
    【解决方案2】:

    解决方案 - 可能会帮助有类似问题的人:

    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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 1970-01-01
      相关资源
      最近更新 更多