简体   繁体   中英

Rails/Sidekiq/Devise: Is the job being handled by Sidekiq? How can I be sure?

I've set Devise to send emails asynchronously, like so:

class User < ApplicationRecord
  ...

  def send_devise_notification(notification, *args)
    DeviseMailerJob.perform_now(devise_mailer, notification, id, *args)
  end
end

class DeviseMailerJob < ApplicationJob
  queue_as :mailers

  def perform(devise_mailer, method, user_id, *args)
    user = User.find(user_id)
    devise_mailer.send(method, user, *args).deliver_now
  end
end

My sidekiq.yml looks like this:

---
:concurrency: 5
:queues:
  - mailers

I can go to the sign up page, sign up and I will see that everything seems ok in the logs:

2018-10-09T10:02:27.793848+00:00 app[web.1]: I,
[2018-10-09T10:02:27.793770 #4]  INFO -- :
[646a58f7-9588-4a1f-a258-9fbede3cf87d] [ActiveJob] [DeviseMailerJob]
[5ceac77e-d498-4436-8f12-7cd4aff2c004] Performed DeviseMailerJob (Job ID:
5ceac77e-d498-4436-8f12-7cd4aff2c004) from Sidekiq(mailers) in 3301.06ms

But the job does not show up in the Sidekiq dashboard. I do receive the confirmation email however. So the job does get processed. Only, I cannot be sure that Sidekiq is handling it.

Looking at the Heroku logs, I cannot see any logs from Sidekiq. On the dashboard, I would expect to see the 'processed' tally increment for every email that is sent. I'm not sure how to investigate this.

With Heroku, what's the best way of seeing wether or not the job is being handled by Sidekiq? Is there anything in my code to suggest that the job isn't being handled by Sidekiq?

您已经通过调用perform_now明确告知代码立即执行:

DeviseMailerJob.perform_now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM