入队后延迟工作未履行

时间:2017-10-26 01:38:57

标签: ruby-on-rails delayed-job

我有一个自定义的工作类:

class RemoteServiceNotifierJob < Struct.new(:object_id, :object_class, :action)

  def self.enqueue(object_id, object_class, action)
    job = new(object_id, object_class, action)

    Delayed::Job.enqueue job, queue: 'remote_service_notifier'
  end

  def perform
    RestClient.post(url, params, content_type: 'application/json') { |response, request, result, &block|
      unless response.code == 201
        raise RemoteServiceNotifierError
      end
    }
  end

end

当我在rails console上运行时:

RemoteServiceNotifierJob.enqueue id, 'ServiceRequest', 'update' 

插入延迟作业,然后立即删除。

我已将延迟的作业配置设置为:

Delayed::Worker.destroy_failed_jobs = false

但延迟的工作永远不会被执行。

1 个答案:

答案 0 :(得分:0)

出于某种原因,在重新部署之后,一切都运转良好。