New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuration of ActionMailer queue name #18587
Allow configuration of ActionMailer queue name #18587
Conversation
require "#{app_path}/config/environment" | ||
require "mail" | ||
|
||
_ = ActionMailer::Base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing I could set the configuration separately from using it.
We need to configure the default AM queue as well in Queue Classic. |
+1 |
I'm thinking of a cleaner approach. ActiveJob::Base accepts a class DeliveryJob < ActiveJob::Base # :nodoc:
queue_as do
ActionMailer::Base. deliver_later_queue_name || :mailers
end
end what do you think @chrismcg? |
@cristianbica I'm not sure I understand the benefit of that approach. Why not set |
@senny yeah the |
@cristianbica |
@cristianbica sorry, I've only just seen your comment. I didn't know you could use a proc there so I'll have a look at it later in the week when I've a bit more time. |
+1 |
@cristianbica finally got around to doing that change. I think it's clearer this way. |
Please squash your commits. Otherwise seems good to me. |
1948144
to
f5a131a
Compare
Commits squashed, thanks! |
…e_to_be_configured Allow configuration of ActionMailer queue name
Also add a CHANGELOG entry for #18587 [ci skip]
Is there a specific reason why this didn't make it into 4.2.4? Judging by this PR, I thought it would be included since this has been merged on June 3, but 4.2.4 wasn't released until August 24. |
@michaelsauter new features aren't backported to bugfix releases. |
@matthewd Ah okay, thanks. Though I think this almost counts as a bugfix ;) |
I'm trying to set up separate mailer queues for transaction mail processing and bulk mail processing in my Rails 5.1.3 application. I was hoping to be able to designate the queue by setting the
This works fine for the smtp_settings, but the Is there a way for me to set separate |
Also curious about @rossinkiwi 's question |
The `deliver_later_queue_name` is already configurable on ActionMailer::Base, however the value is inherited by all subclasses. Use a class-inheritable attribute instead, so that subclasses can override. Refs: - rails#18587 (comment)
The `deliver_later_queue_name` is already configurable on ActionMailer::Base, however the value is inherited by all subclasses. Use a class-inheritable attribute instead, so that subclasses can override. Refs: - rails#18587 (comment)
Currently all mails sent with
deliver_later
are put on themailers
queue. This patch keeps that default but allows the queue name to be configured globally.The motivation was trying to use https://github.com/chanks/que as the queuing backend. It's a good fit for a simple queue for a single dyno heroku app but by default only listens to one queue per application. As ActiveJob will use the
default
queue and ActionMailer themailers
queue jobs wouldn't get run.The Que library might change to support more than one queue but in the meantime this will allow Rails to work with it. It will also be useful for users of other backends who might need to change where mails are queued.