Created
October 4, 2023 16:28
-
-
Save jjb/2975e479ac6d982be966e78e6aecd924 to your computer and use it in GitHub Desktop.
How to set sidekiq options for ActionMailer / ActiveJob / MailDeliveryJob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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