Coder Social home page Coder Social logo

ActiveJob #deliver_later! ignores queue settings in config/shoryuken.yml and always try to use "mailers" queue about shoryuken HOT 11 CLOSED

ruby-shoryuken avatar ruby-shoryuken commented on June 15, 2024
ActiveJob #deliver_later! ignores queue settings in config/shoryuken.yml and always try to use "mailers" queue

from shoryuken.

Comments (11)

rusllonrails avatar rusllonrails commented on June 15, 2024

Ahh looks like Rails Mailer uses mailers queues when delivering email

from shoryuken.

rusllonrails avatar rusllonrails commented on June 15, 2024

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.

rusllonrails avatar rusllonrails commented on June 15, 2024

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.

rjungemann avatar rjungemann commented on June 15, 2024

@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.

rusllonrails avatar rusllonrails commented on June 15, 2024

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.

phstc avatar phstc commented on June 15, 2024

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.

rusllonrails avatar rusllonrails commented on June 15, 2024

@phstc yeah, that make sence.
Thanks 🍻

from shoryuken.

kesha-antonov avatar kesha-antonov commented on June 15, 2024

Thanks for this. Useful!

from shoryuken.

gshutler avatar gshutler commented on June 15, 2024

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.

rusllonrails avatar rusllonrails commented on June 15, 2024

sounds good 👍

from shoryuken.

phstc avatar phstc commented on June 15, 2024

nice 👍

from shoryuken.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.