1

I've just changed my job scheduler from delayed_jobs to sidekiq on my Rails app. In Delayed_jobs, once we deleted an instance of the model Order, we then deleted the related jobs like this:

jobs = Delayed::Job.where("handler LIKE '%/Order/?%'", id).where(queue: queue)
jobs&.destroy_all

Now, as Sidekiq doesn't work on our DB, I've used the documentation from the Sidekiq API and been trying to do it this way:

rs = Sidekiq::RetrySet.new
ss = Sidekiq::ScheduledSet.new
ds = Sidekiq::DeadSet.new
[rs, ss, ds].each do |set|
   set.scan("Order/#{id}").map(&:delete) if set.any?
end

The problem with this is that I'm not searching in the specific queue, so any job related with the instance Order/id will be deleted and I want to delete just the ones in an specific queue.

  • You may want to check out [this answer](https://stackoverflow.com/a/21101810/2622934). Then you can apply that same idea to things like `Sidekiq::DeadSet`. – cschroed Mar 28 '21 at 15:12

0 Answers0