Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a default queue for ActionMailer deliver_later?

Tags:

You can specify which queue to use when calling deliver_later in an ActionMailer by adding :queue as optional argument, e.g.:

Notifier.welcome(User.first.id).deliver_later(queue: "low")

Is there a way to do this in a general way, for all ActionMailers? To set the default ActionMailer queue?

like image 993
Hallgeir Wilhelmsen Avatar asked Jan 30 '15 22:01

Hallgeir Wilhelmsen


1 Answers

Before Rails 5

Looking through Rails' source code you can see that they already set the default queue name as 'mailers'.

Still, if you want to change that default you can always override it by including the following code in an initialiser or loaded lib file:

class ActionMailer::DeliveryJob   queue_as :default_mailer_queue end 

Since Rails 5

Rails 5 allows you to set the default queue naming by simply configuring it.

E.g. add to you application.rb:

config.action_mailer.deliver_later_queue_name = 'default_mailer_queue' 
like image 198
mrstif Avatar answered Oct 01 '22 20:10

mrstif