Search code examples
ruby-on-railssidekiqrails-activejob

Advantages when using ActiveJob with Sidekiq compare with Sidekiq alone


I'm reading some tutorials online that tell us using ActiveJob with Sidekiq. But I don't know why we should do that. I see that Sidekiq has all features that ActiveJob has.

Moreover, on Sidekiq document: here

Warning: by doing job retry through ActiveJob, you lose a lot of Sidekiq functionality:

  1. Web UI visibility (the Retries tab will be empty)
  2. You cannot iterate through retries with the Sidekiq::RetrySet API.
  3. Sidekiq's log will not contain any failures or backtraces.
  4. Errors will not be reported to Sidekiq's global error handlers
  5. Many advanced Sidekiq features (e.g. Batches) will not work with AJ retries.

That is a signal somehow make me think that we shouldn't use Sidekiq with ActiveJob. Do I understand wrong about ActiveJob ? Are there any advantages when using ActiveJobs with sidekiq ?

Thanks


Solution

  • From rails ActiveJob guide

    The main point is to ensure that all Rails apps will have a job infrastructure in place. We can then have framework features and other gems build on top of that, without having to worry about API differences between various job runners such as Delayed Job and Resque. Picking your queuing backend becomes more of an operational concern, then. And you'll be able to switch between them without having to rewrite your jobs.

    basically what ActiveJob does is standardising the API interface for job queuer. This will help you to change from one job backend to the other with ease.

    When you use Sidekiq with ActiveJob, you can benefit from the goodies sidekiq has to offer, but the real catch is when you find another queuer is best for your application, ActiveJob allows you to switch to your job queuer of choice with a one liner

    # application.rb
    config.active_job.queue_adapter = :sidekiq