3
votes

Ive just installed redis and sidekiq on my app,

I Have a job to update a field on the users table when called upon,

And a job that sends an email once a week to all users.

Now if i boot up sidekiq with bundle exec sidekiq The job to update the users field fires off and completes but the email job stays in the enqueued section.

But if i boot it up with bundle exec sidekiq -q workers -q mailers Which i got from the Sidekiq github page only the mail jobs get completed and the others stay in the enqueued section.

Is there a command to be able to run both? Ive only started to learn about sidekiq and redis yesterday so sorry if this a stupid question,

I have the activejob.que_adaptar set to sidekiq in application.rb.

This is how i have my sidekiq worker for the User job set up:

class DeactivateUser
 include Sidekiq::Worker

  def perform
   User.active.update_all(active: false)
  end

end

Thanks.

2
Likely the problem is that you aren't listing 'default' as a queue to process.Mike Perham
Hi @MikePerham, Thanks for the reply, Do i also need to list the 'mailer' queue on for the mailer job? Its weird you've replied as i only just watched a lecture you gave on sidekiq a couple of days back!john seymour
You need to list whichever queues you want to process. I would just send all jobs to default, why add extra queues?Mike Perham

2 Answers

1
votes

As Oskar configured, follow the same approach to have multiple queues processed by single sidekiq process. In addition, you have to mention the queue name in the worker file. So that the sidekiq process will get the jobs from redis of that queue. For ex: ( sidekiq_options queue: :mailers )

class WORKER_NAME
  include Sidekiq::Worker
  sidekiq_options queue: :<queue_name>

   def perform
     ... # your work
   end
end

If you want to start process only listening to one queue mailers and having concurrency 10, please start like this.

bundle exec sidekiq -c 10 -C config/myapp_sidekiq.yml -q mailers -q queue1 -q queue2

This will listen to total of 3 queues named mailers, queue1, queue2. This is how you will have to start the sidekiq. For more documentation, please refer to this.

2
votes

Create config/sidekiq.yml with list of your queues and run sidekiq -C config/sidekiq.yml.

    #config/sidekiq.yml

    ---
    :concurrency: 5
    :queues:
      - default
      - mailers
      - orders