'How to check the sidekiq queue

In a separate tab, I'm running

bundle exec sidekiq

and in another tab I'm running:

SendWithUsInviteeMailerJob.perform_async(invitee.id)

which kicks off a job that is here:

class SendWithUsInviteeMailerJob
  include Sidekiq::Worker
  sidekiq_options queue: :mailer, retry: 2

  def perform(invitee_id)
    SendWithUsInviteeMailer.welcome(invitee_id).deliver
  end
end

How do I determine if this job is enqueued in sidekiq? Say this is a test environment. I basically want to see that this job was enqueued for the purposes of a test.

Here's my gemfile:

... gem 'sidekiq' gem 'redis' ...

and in my spec_helper:

require 'sidekiq/testing'

  config.before(:each) do
    Sidekiq::Worker.clear_all
  end
end

Sidekiq::Testing.fake!


Solution 1:[1]

There are multiple ways to do that. One way is by using Sidekiq::Web, a nice graphical interface for viewing scheduled, enqueued, busy, processed, retries, and faild jobs:

https://github.com/mperham/sidekiq/wiki/Monitoring

Another way is by using the terminal. Run redis-server and sidekiq to start up the services. Now, in the the rails cunsole type SendWithUsInviteeMailerJob.perform_async to execute the job, which then will be shown in the terminal pane running sidekiq.

Alternatively, call Sidekiq::enqued_jobs(queue: :mailer) in the rails console to get an array of mailer jobs. However, with fast jobs you need to type equally fast in order to catch the job before it has been send to busy jobs (Sidekiq::busy_jobs) and been executed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr. Jaeger