2

I have a method like this one

  def abc
     // some stuff here
  end
  handle_asynchronously :abc, queue: :xyz

I want to create a delayed job for this only if there isn't one already in the queue.

I really feel like this should have an easy solution

Thanks!

vladCovaliov
  • 4,333
  • 2
  • 43
  • 58
  • Take a look at this: http://stackoverflow.com/questions/20473471/sidekiq-ensure-all-jobs-on-the-queue-are-unique/21481379#21481379 – Freddy Wetson May 30 '14 at 20:05

1 Answers1

1

I know this post is old but it hasn't been replied. Delayed jobs does not provide a way to identify jobs. https://github.com/collectiveidea/delayed_job/issues/192

My suggestion is that your job could check if it still has to run when it is executing, for example, comparing to a database value, etc. Inserting jobs in the table should be quick and you might lose that if you start checking for a certain job in the queue.

If you still want to look for duplicates when enqueuing, this might help you. https://gist.github.com/landovsky/8c505ecab41eb38fa1c2cd23058a6ae3

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Leticia Esperon
  • 2,499
  • 1
  • 18
  • 40