Search code examples
ruby-on-railssidekiq

send email with active job and sidekiq


I have an active job that sends an email

class UpdateEmailJob < ActiveJob::Base

  queue_as :default

  def perform()
    NotificationsMailer.create_client("[email protected]").deliver
  end
end

Then on my code I call the perform later method

UpdateEmailJob.perform_later

I am getting a message that the job has been Enqueued

[ActiveJob] Enqueued UpdateEmailJob (Job ID: 1a57232b-f6a8-4dc6-b612-8aca1b1dba2c) to Sidekiq(default)

But the email is not been send, how can I debug that ? Is there a way to explore the queue ? is there a way to force the worker to run all the queue jobs ?


Solution

  • Do you have the sidekiq mailers queue running? If not, run this:

    bundle exec sidekiq -q default -q mailers
    

    You can interact and debug enqueued jobs via the Sidekiq API. Run rails c, then:

    require 'sidekiq/api'
    
    Sidekiq::Queue.new("mailers")
    

    This provide all of the jobs currently enqueued in mailers. From there, look at the API docs for different ways to inspect them.