Abram
Abram

Reputation: 41954

ActiveJob deliver_later not sending

I have the following method:

UserMailer.comment_alert(@comment, user, type).deliver_later

Which oddly shows up with the param deliver_now in the rails log:

[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 5bdf9ed1-53d5-42aa-acb2-7ce54ab284e1) to Sidekiq(mailers) with arguments: "UserMailer", "comment_alert", "deliver_now", gid://xxx/Comment/153, gid://xxx/User/26, "Comment"

The job never processes, and I see nothing in the Sidekiq log. There is also no mail delivered, ever. I tried restarting sidekiq, rails, and redis, and even clearing the redis db. Interestingly changing to .deliver_now works, but this doesn't seem to touch sidekiq or create an Enqueued ActionMailer::DeliveryJob

In my application.rb:

config.active_job.queue_adapter = :sidekiq

I am using rails 4.2.6 with activejob 4.2.6

Upvotes: 8

Views: 8577

Answers (2)

If you are working with sidekiq don't use deliver later because the job never performs, instead use perform_in(<>) and call a worker with deliver_now inside

Upvotes: -3

Kenny Chan
Kenny Chan

Reputation: 1232

Mailers are queued in the queue mailers. Remember to start sidekiq processing that queue:

bundle exec sidekiq -q default -q mailers

Or add config/sidekiq.yml with the following content

  :verbose: true
  :concurrency: 25
  :queues:
    - [mailers, 7]
    - [default, 5]

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

Upvotes: 25

Related Questions