Py学习  »  Redis

rails-5 active_作业sidekiq无法将作业直接推送/添加到redis命名队列中

brg • 4 年前 • 386 次点击  

我试图将作业直接添加到redis中,但它引发了以下错误:

  WARN: NoMethodError: undefined method `split' for nil:NilClass
  2018-11-03T00:45:14.826Z 31 TID-gst0yl4s0 WARN: 
  /usr/local/bundle/gems/sidekiq-5.0.3/lib/sidekiq/processor.rb:233:in `      constantize'

这是我正在运行的命令:

msg = {
   arguments: [{
     '_aj_globalid' =>  'gid://app-name/Article/25'
   },
   [{name: 'jamis'}]
 ],
   'job_class' => 'ImporterJob',
   'job_id' => SecureRandom.uuid,
   'queue_name' => 'importer_job'
 }

 redis.lpush("queue:importer_job", JSON.dump(msg) )

这将失败,下面显示的下一次尝试也将失败:

 msg = {
   args: [{
     arguments: [{
       '_aj_globalid' =>  'gid://app-name/Article/25'
     },
     [{name: 'jamis'}]
   ],
     'job_class' => ImporterJob,
     'job_id' => SecureRandom.uuid,
     'queue_name' => 'importer_job'
   }]
 }

redis.lpush("queue:importer_job", JSON.dump(msg) )

我在下面的两个工作类中都试过了,得到了同样的错误:

class ImporterJob < ActiveJob::Base
  queue_as :importer_job
  def perform(data)
    puts "datis #{data}"
  end
end

这需要一个普通的sidekiq工作者

class ImporterJob
  include Sidekiq::Worker
  sidekiq_options queue: 'importer_job'

  def perform(data)
    puts "datis #{data}" 
  end
end

msg = { "class" => 'UbiquityCsvImporterJob',
"queue" => 'ubiquity_csv',
"args" => values,
'retry' => true,
'jid' => SecureRandom.hex(12),
'created_at' => Time.now.to_f,
'enqueued_at' => Time.now.to_f }
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/47704
 
386 次点击