使用带有RabbitMQ的运动鞋时Ruby on Rails错误

时间:2016-08-25 07:36:25

标签: ruby-on-rails rabbitmq worker

我正在使用sneakers gem来触发RabbitMQ上的动作 但我无法启动我的服务来触发

我运行命令

WORKERS=MailerWorker rake sneakers:run

我收到错误

[INFO] 160825 14:26:46 :: LAUNCH worker
rake aborted!
NameError: uninitialized constant ApplicationCable::ActionCable
/home/hdthinh/wthapps/admin-api/app/channels/application_cable/channel.rb:3:in `<module:ApplicationCable>'
/home/hdthinh/wthapps/admin-api/app/channels/application_cable/channel.rb:2:in `<top (required)>'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/activesupport/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/activesupport/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/activesupport/lib/active_support/dependencies/interlock.rb:11:in `loading'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/railties/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/railties/lib/rails/engine.rb:475:in `each'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/railties/lib/rails/engine.rb:475:in `block in eager_load!'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/railties/lib/rails/engine.rb:473:in `each'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bundler/gems/rails-804f5b3c2af9/railties/lib/rails/engine.rb:473:in `eager_load!'
/home/hdthinh/.rvm/gems/ruby-2.3.0/gems/sneakers-2.3.5/lib/sneakers/tasks.rb:13:in `block (2 levels) in <top (required)>'
/home/hdthinh/.rvm/gems/ruby-2.3.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/home/hdthinh/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

我的代码在

之下
# Rakefile
require_relative 'config/application'
require 'sneakers/tasks'

Rails.application.load_tasks


# config/initializers/sneakers.rb
Sneakers.configure({})
Sneakers.logger.level = Logger::INFO

# app/workers/mailer_worker.rb
require 'sneakers'
class MailerWorker
  include Sneakers::Worker

  from_queue "test.user.login", env: nil

  def work(raw_post)
    p "you are successful in this queue! #{raw_post.to_s}"
    ack! # we need to let queue know that message was received
  end
end

我的RabbitMQ也在交换时发出消息&#34; test.user.login&#34;

我遵循了这篇文章,但发生了错误 Rails: How to listen to / pull from service or queue?

我怎样才能毫无错误地运行运动鞋

由于

1 个答案:

答案 0 :(得分:1)

错误表示您的脚本中没有ActionCable,您应该在脚本中安装/需要它。