Sidekiq not processing queue

The reason was in our case: Sidekiq may look for the wrong queue. By default Sidekiq uses a queue named "default". We used two different queue names, and defined them in config/sidekiq.yml

# configuration file for Sidekiq
:queues:
  - queue_name_1
  - queue_name_2

The problem is that this config file is not automatically loaded by default in your development environment (unlike database.yml or thinking_sphinx.yml for instance) by a simple bundle exec sidekiq command. Thus we wrote our jobs in two certain queues, and Sidekiq was waiting for jobs in a third queue (the default one). You have to pass the path to the config file as a parameter through the -Cor --config option:

bundle exec sidekiq -C ./config/sidekiq.yml

or you can pass the queue names directly (no spaces allowed here after the comma):

bundle exec sidekiq -q queue_name_1,queue_name_2

To find the problem out it is helpful to pass the option -v or --verbose at the command line, too, or to use :verbose: true in the sidekiq.yml file. Everything which is defined in a config file is of course useless if the config file is not loaded.. Therefore make sure you are using the right config file first.


If you have a config/sidekiq.yml check that all the queues are defined there, check this sample file: https://github.com/mperham/sidekiq/blob/master/examples/config.yml

If you are passing queue names in the command line or Procfile, something similar to

bin/sidekiq -q queue1 -q queue2
bundle exec sidekiq -q queue1 -q queue2

check that all your queues are defined there.

In case you are not sure about the names of your queues, you can figure it out with the following script:

require "sidekiq/api"
stats = Sidekiq::Stats.new
stats.queues
# {"production_mailers"=>25, "production_default"=>1}

Then, you can do things with the queues:

queue = Sidekiq::Queue.new("production_mailers")
queue.count
queue.clear

It took me hours to find out that I had set config.active_job.queue_name_prefix = "xxxxx_#{Rails.env}". The queue names in the settings look the same, but sidekiq looks for the queue with prefix.

Wrong setting

app/jobs/my_job.rb

class MyJob < ApplicationJob
  queue_as :default
end

config/sidekiq.yml

:queues:
  - default

Correct setting

app/jobs/my_job.rb

class MyJob < ApplicationJob
  queue_as :default
end

config/sidekiq.yml

:queues:
  - xxxxx_development_default
  - xxxxx_production_default