繁体   English   中英

Sidekiq 没有找到 Rails Active Job 的记录

[英]Sidekiq not finding records for Rails Active Job

在模型中创建用户后,作业将排队

用户.rb

after_create_commit :profile_photo_job

def profile_photo_job
    message = "Add a profile photo"
    ReminderJob.set(wait: 1800).perform_later(self.id.to_s, message)
end

提醒工作.rb

class ReminderJob < ApplicationJob
  queue_as :default

  def perform(user_id, message)
    if user_id
      user = User.find(user_id)
    end
    ##sending message notification here
  end

end

但是,它经常在我的 sidekiq 控制台中引发以下错误

ActiveRecord::RecordNotFound: 找不到 'id'=7749 的用户处理器: User-MacBook-Pro.local:*****

此错误发生在生产中。

在用户.rb

after_commit :profile_photo_job, on: :create

def profile_photo_job
    message = "Add a profile photo"
    ReminderJob.set(wait: 1800).perform_later(self.id.to_s, message)
end

我遇到了这个问题,工人返回错误:

ActiveRecord::RecordNotFound: Couldn't find User with 'id'

我尝试了很多东西,并意识到我有2 个独立的 Rails 应用程序(具有不同的数据库)从同一个队列中读取。 愚蠢的错误,但是一旦我更改了其中一个应用程序的队列名称,我就再也没有看到这个。

如果有人没有检查这个,就把这个留在这里🤦‍♂️

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM