问题描述
尝试实现某种取消作业功能.为了
我只希望参数值位于外括号内.我正在创建这样的工作:
PhysicalServerProvisionJob.perform_later('123')
我希望能够:
Resque::Job.destroy(:default, PhysicalServerProvisionJob, '123')
然而,由于传入的额外信息,这是不可能的.如果这是不可避免的,是否有另一种方法来销毁特定的排队作业?
在这里的答案的帮助下,我解决了问题是这样的:
Resque.size('default').times 做job = Resque.reserve('默认')下一个如果job.nil?||job.args.first['arguments'].first == idResque.push('default', class: job.payload_class.to_s, args: job.args)结尾
Trying to implement some kind of cancel job functionality. In order to destroy a job with Resque, one needs the specific arguments passed to it. It appears I'm passing in unintended information by mistake though.
I'm expecting just the arguments value to be within the outside brackets. I'm creating the job like so:
PhysicalServerProvisionJob.perform_later('123')
I'd like to be able to:
Resque::Job.destroy(:default, PhysicalServerProvisionJob, '123')
However this isn't possible due to the extra information passed in. If this is unavoidable, is there another way to destroy a specific queued job?
With help from this answer here, I solved the problem this way:
Resque.size('default').times do
job = Resque.reserve('default')
next if job.nil? || job.args.first['arguments'].first == id
Resque.push('default', class: job.payload_class.to_s, args: job.args)
end
这篇关于带有 Resque 的 ActiveJob:使用意外参数排队作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!