Sidekiq在默认值'队列而不是邮件'队列

发布于 2025-02-10 09:13:19 字数 1336 浏览 1 评论 0原文

在将Rails 6.0申请升级到Rails 7.0.3时,我面临以下问题:

Sidekiq正在通过默认>默认队列而不是Mailers queue来吸引我所有的Mailer作业。就像以前一样。

与同一相关的代码:

在Application.RB:

    config.active_job.queue_adapter = :sidekiq

我的Mailer中:


class UserMailer < ActionMailer::Base

  def staff_welcome(user, password)
    @user = user
    @password = password
    mail(to: user.email, from: "DummyName <#{APP_CONFIG[:notifications_email]}>", reply_to: "#{APP_CONFIG[:outbound_email]}", subject: "Your staff account has been created")
  end

然后,在控制器内,我将邮件呼叫以下:

def create
    @user = User.new
    @user.attributes = users_params.merge(state: 'active', source: :dummy_source, activity: 1)

    set_roles(users_params)
    respond_to do |format|
      if @user.save
        if @user.staff?
          UserMailer.staff_welcome(@user, params[:user][:password]).deliver_later


我有兴趣找出为什么升级为Rails 7时,我的邮递员是更改邮件的队列吗?当我使用Rails 6运行服务器时,邮件器会通过Mailers队列排队,但是使用Rails 7,队列为default

我知道,如果我从ActiveJob内部调用邮件器,并且在控制器内部调用该作业,而不是直接调用邮件器,我将能够使用语法,例如queue_as:mailers。这是解决此问题的正确方法吗?

我检查了sidekiq的变频器,但找不到与此相关的任何内容?当涉及邮件时,他们是否更改了默认队列?

另外,我可以使用driver_later函数设置sidekiq_options吗?

While upgrading my Rails 6.0 application to Rails 7.0.3, I'm facing the following problem :

Sidekiq is enqueueing all my mailer jobs through the default queue instead of the mailers queue like it used to before.

Code related to the same :

in application.rb :

    config.active_job.queue_adapter = :sidekiq

My mailer :


class UserMailer < ActionMailer::Base

  def staff_welcome(user, password)
    @user = user
    @password = password
    mail(to: user.email, from: "DummyName <#{APP_CONFIG[:notifications_email]}>", reply_to: "#{APP_CONFIG[:outbound_email]}", subject: "Your staff account has been created")
  end

And then, inside the controller, i'm calling the mailer as follows :

def create
    @user = User.new
    @user.attributes = users_params.merge(state: 'active', source: :dummy_source, activity: 1)

    set_roles(users_params)
    respond_to do |format|
      if @user.save
        if @user.staff?
          UserMailer.staff_welcome(@user, params[:user][:password]).deliver_later


I'm interested in finding out why upon upgrading to Rails 7 is my queue for mailers changing? When i run the server with Rails 6, the mailers get queued via the mailers queue, but with Rails 7, the queue is default.

I understand that if i call the mailer from inside an ActiveJob, and inside the controller call the job instead of the mailer directly, I will be able to use syntax like queue_as :mailers. Is that the correct way to fix this?

I checked the changelog for sidekiq but couldn't find anything related to this? Did they change the default queue when it comes to mailers?

Also, can i set sidekiq_options with the deliver_later function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や莫失莫忘 2025-02-17 09:13:19

在Rails 6.1中,他们更改了默认队列名称。

有关更改此处的更多信息: https://github.com/rails/rails/rails/rails/rails/pulls/pull/407666

在Sidekiq文档中:
https://github.com/sidekiq.com/sidekiq/sidekiq /stey队列

In Rails 6.1, they changed the default queue name.

More info on the change here: https://github.com/rails/rails/pull/40766

In the Sidekiq documentation:
https://github.com/sidekiq/sidekiq/wiki/Active-Job#queues

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文