Comments (11)
Ahh looks like Rails Mailer uses mailers queues when delivering email
from shoryuken.
yep.
require 'active_job'
module ActionMailer
# The <tt>ActionMailer::DeliveryJob</tt> class is used when you
# want to send emails outside of the request-response cycle.
class DeliveryJob < ActiveJob::Base # :nodoc:
queue_as :mailers
def perform(mailer, mail_method, delivery_method, *args) #:nodoc:
mailer.constantize.public_send(mail_method, *args).send(delivery_method)
end
end
end
from shoryuken.
Looks like we can only set following ops for DeliveryJob class:
config.active_job.queue_name_prefix = Rails.env
config.active_job.queue_name_delimiter = '.'
And can override name only in separated classes like:
class ExampleJob < ActiveJob::Base
# Set the Queue as Default
queue_as :default
def perform(*args)
# Perform Job
end
end
Yep. That's fine =)
Sorry for disturbing guys and thanks for nice gem 👍
I think it's good to close
from shoryuken.
@RuslanHamidullin I'm glad that you found a solution to your issue, but I can't figure out how to get it to work given the information you provided. How do I override my mailer to use a different queue other than "mailers"?
from shoryuken.
hey @rjungemann
So there are no easy way to specify custom 'queue' name per mailer.
On my app I solved problem via using convention:
Each environment have 1 queue for app jobs, and 1 queue for mailers
I added config/initializers/active_job_shoryuken.rb
Rails.application.configure do
if Rails.env.staging? || Rails.env.production?
# For 'Staging' and "Production" use 'shoryuken' adapter
config.active_job.queue_adapter = :shoryuken
config.active_job.queue_name_prefix = Rails.env
config.active_job.queue_name_delimiter = "_"
else
# Use default active job 'inline' adapter for 'Test' and 'Development' environments
config.active_job.queue_adapter = :inline
end
end
So that for staging would be 2 queues:
staging_default # For app jobs
staging_mailers # For mailers
And similar for production:
production_default
production_mailers
from shoryuken.
Hi @RuslanHamidullin
I'm glad you found that out. I would recommend you to have more granular queues per jobs, so you would be able to configure their priorities separately with Shoryuken.
Another option for the queue_name_prefix
, would be to use something like ENV['USER']
in development, so the developers can have individual queues to "facilitate" their tests.
Here we use ENV variables (dotenv in development) to configure the queue prefixes.
from shoryuken.
@phstc yeah, that make sence.
Thanks 🍻
from shoryuken.
Thanks for this. Useful!
from shoryuken.
I was looking into this and found this thread. For future reference this has been made configurable via config.action_mailer.deliver_later_queue_name
rails/rails#18587 but hasn't made it into a release at the time of writing.
from shoryuken.
sounds good 👍
from shoryuken.
nice 👍
from shoryuken.
Related Issues (20)
- How to arrive at the latency for a given Shoryken::Queue? HOT 4
- Question about max_number_of_messages and concurrency HOT 6
- Best Practices for configuration - Plain Ruby HOT 2
- Load balancing vs the default pooling strategy documentation HOT 3
- Environment Variables in *.yml files are not resolved HOT 5
- Doubt about threads opened with concurrency in groups HOT 2
- Doubt about delay in groups HOT 2
- FIFO queues and `retry_on` seem incompatible HOT 2
- Can concurrency be shared across groups (Managers) ? HOT 7
- Add Support for Non-retryable Exception to Shoyuken HOT 4
- Documentation for setting Receive Message options are confusing/unexpected when used with groups HOT 4
- delay in 'batch: true' option taking effect on startup HOT 6
- Feature: after stop callback
- When in Rails mode, in development environment, does not load app/workers automatically HOT 4
- Process terminated when started from Procfile HOT 3
- SIGTERM does not stop dispatching of new messages from the queue HOT 4
- Exception in Shoryuken::Queue#receive_messages HOT 3
- Not able to extend polling strategy when using yaml syntax for configuration.
- Support for ActiveJob.perform_all_later (Rails 7.1) HOT 5
- Thread vs Process | Performance Bottleneck HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shoryuken.