Skip to content

Instantly share code, notes, and snippets.

@jjb
Created October 4, 2023 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjb/2975e479ac6d982be966e78e6aecd924 to your computer and use it in GitHub Desktop.
Save jjb/2975e479ac6d982be966e78e6aecd924 to your computer and use it in GitHub Desktop.
How to set sidekiq options for ActionMailer / ActiveJob / MailDeliveryJob
# in default config, ActionMailer will use sidekiq wrapped in ActiveJob
# This makes it so there is no obvious/direct place to specify configuration
# It's easy to do with the below method, which can be placed in an initializer
Rails.application.config.after_initialize do
ActionMailer::MailDeliveryJob.class_eval do
sidekiq_options retry: 2
end
end
# n.b. This does NOT work, because initializers run before the railtie which sets
# up the ActionMailer / ActiveJob / sidekiq relationship
# ActionMailer::MailDeliveryJob.class_eval do
# sidekiq_options retry: 2
# end
# but it can be used for other non-sidekiq things,
# e.g. https://github.com/mastodon/mastodon/blob/main/config/initializers/mail_delivery_job.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment