ActiveJob deliver_later not sending

会有一股神秘感。 提交于 2019-12-08 19:42:46

问题


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


回答1:


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




回答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



来源:https://stackoverflow.com/questions/37871943/activejob-deliver-later-not-sending

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!