17

I have a rails app in which I have a method where I send a lot of emails. I would like to perform this action asynchronously. To do it I've tried to use Sidekiq, but I can't get it to work properly - it doesn't send any emails.

Sending email worked before, so I'm certain that my email settings is set ut correctly.

In my gemfile I have this:

gem 'sidekiq'

And I have run bundle install. I have also install redis, followed the instructions on RailsCasts #366.

I have started sidekiq with the following command: bundle exec sidekiq, this resulted in what can be seen in the image below:

enter image description here

In application.rb I have the following:

config.active_job.queue_adapter = :sidekiq

And I try to send the emails like this:

Mailer.deliver_new_competition_notification(member.user,   @competition).deliver_later!

I don't get any errors, but the emails never gets sent.

So, have I missed something?

Anders
  • 2,903
  • 7
  • 58
  • 114
  • Have you included a proc file? – sansarp Mar 01 '15 at 16:58
  • @sansarp No, I have not. Anthony's answer below was enough to make it work. But I'm curious about Procfiles, could you elaborate on how I can include ad Procfile, what it should contain and why? – Anders Mar 01 '15 at 18:20

2 Answers2

46

You need to bootup sidekiq with the mailer queue for it to pick up these jobs:

bundle exec sidekiq -q default -q mailers

The Sidekiq Wiki goes over the scenarios in detail here.

Anthony
  • 15,435
  • 4
  • 39
  • 69
7

Also you can modify the config/sidekiq.yml:

---
:concurrency: 25
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - default
  - mailers

And run sidekiq -C config/sidekiq.yml

Xan Admin
  • 71
  • 1
  • 2