I’m working on a project at the moment in which DelayedJob was the one responsible for doing all the background job. For a new feature, we have decided to use Sidekiq instead…
It was going well until I remembered that both of them implements the method delay.
It is known that DelayedJob stores the job into a MySQL database (in our case) and process it later. On the other hand, Sidekiq uses redis for handling the jobs.
It is our intention to move all the backgound work to Sidekiq one day, but that’s a whole another story.
Just to mention, in order not to worry about the delay method in DelayedJob, we can setup like this:
Delayed::Worker.delay_jobs = falseThis will ignore everytime you call a method through delay and your specs are good to go.
my_object.delay.my_methodIf you prefer, you can disable it only for the test environment.
Delayed::Worker.delay_jobs = !Rails.env.test?After adding Sidekiq gem to Gemfile I realized that a huge amount of tests broke!
Fortunately, we can disable the delay method in order not to conflict with the ones implemented by DelayedJob.
Sidekiq.remove_delayThis will disable all the delay_ method that Sidekiq implements:
- delay
- delay_for
- delay_untilIf you still want them to be used by both Sidekiq and DelayedJob, you can still make it happen.
Sidekiq.hook_railsThis will give you the opportunity to use them as:
- sidekiq_delay
- sidekiq_delay_for
- sidekiq_delay_untilYou can read more about it here
Cheers.