Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you go about rescheduling a job in Sidekiq?

I have implemented scheduled notifications using Sidekiq. I want to also add an ability of rescheduling jobs that haven't been run yet. I do see a reschedule method in the sidekiq api code https://github.com/mperham/sidekiq/blob/061068c551bd96eb6aa790dda0a4dad85bf55381/lib/sidekiq/api.rb but I am not sure what to pass as the arguments when initializing the SortedEntry class. There are no examples in the documentation so I was wondering if anybody has any experience with Sidekiq rescheduling? By the way I grab the jid when I create a job:

message_jid = MessagesWorker.perform_in(@message.deliver_at, msgs2_ids, @message.id)

like image 348
evoo Avatar asked Jan 22 '15 12:01

evoo


People also ask

How do I cancel a Sidekiq job?

According to this Sidekiq documentation page to delete a job with a single id you need to iterate the queue and call . delete on it.

How many jobs can Sidekiq handle?

Today Sidekiq uses a default concurrency of 25. These means Sidekiq will spawn 25 worker threads and execute up to 25 jobs concurrently in a process.

How do I manually run a Sidekiq job?

To run sidekiq, you will need to open a terminal, navigate to your application's directory, and start the sidekiq process, exactly as you would start a web server for the application itself. When the command executes you will see a message that sidekiq has started.


1 Answers

You do this:

Sidekiq::ScheduledSet.new.find_job(@message.jid).reschedule(1.day.from_now)

The find_job call is very slow and will not scale to lots of jobs in the scheduled set. I recommend you either:

  1. Use job cancellation, as documented on the FAQ wiki page.
  2. Use Sidekiq Pro's higher performance API extensions.
like image 143
Mike Perham Avatar answered Sep 29 '22 06:09

Mike Perham