Jerrod Jerrod - 1 year ago 82
Ruby Question

ActiveJob with Resque: enqueuing jobs with uninteded arguments

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.

enter image description here

I'm expecting just the arguments value to be within the outside brackets. I'm creating the job like so:


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?

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download