2

I am using sneakers gem to trigger actions on RabbitMQ But i can not start my service for triggering

I run the command

WORKERS=MailerWorker rake sneakers:run

and I got the error as

[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>'

My codes are below

# 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

My RabbitMQ also have the message at exchange "test.user.login"

I followed this article but errors occurred Rails: How to listen to / pull from service or queue?

How can i run the sneakers without errors

Thanks

Community
  • 1
  • 1
  • Is this helpful http://stackoverflow.com/questions/34396006/uninitialized-constant-actioncableserverconfigurationapplicationcable – Hieu Pham Aug 25 '16 at 08:57
  • Hi @HieuPham, Thanks I have added this line require 'action_cable' to the file 'config/application.rb' It worked well – Thinh Huynh Aug 26 '16 at 03:45

1 Answers1

2

The error says that ActionCable is not available in your script you should install/require it in your script.