Sneakers do not receive messages on the hero - RabbitMQ Bigwig

I am trying to start message queues on heroku. For this, I use the RabbitMQ Bigwig plugin .

I am posting using the bunny gem, and trying to get messages using sneakers. All this setting works smoothly on the local machine.

I do the following steps to set up the queue

I run this rake on the server to install the queue:

namespace :rabbitmq do
    desc 'Setup routing'
    task :setup_test_commands_queue do
      require 'bunny'

      conn = Bunny.new(ENV['SYNC_AMQP'], read_timeout: 10, heartbeat: 10)
      conn.start

      ch = conn.create_channel

      # get or create exchange
      x = ch.direct('testsync.pcc', :durable => true)

      # get or create queue (note the durable setting)
      queue = ch.queue('test.commands', :durable => true, :ack => true, :routing_key => 'test_cmd')

      # bind queue to exchange
      queue.bind(x, :routing_key => 'test_cmd')

      conn.close
    end
  end

I can see this queue in the rabbitmq control plugin with the specified binding.

class TestPublisher
  def self.publish(test)
    x = channel.direct("testsync.pcc", :durable => true)
    puts "publishing this = #{Test}"
    x.publish(Test, :persistent => true, :routing_key => 'pcc_cmd')
  end

  def self.channel
    @channel ||= connection.create_channel
  end

  def self.connection
    @conn = Bunny.new(ENV['RABBITMQ_BIGWIG_TX_URL'], read_timeout: 10, heartbeat: 10) # getting configuration from rabbitmq.yml
    @conn.start
  end
end

I call TestPublisher.publish () to post a post.

I have such a crossover:

require 'test_sync'
class TestsWorker
  include Sneakers::Worker
  from_queue "test.commands", env: nil

  def work(raw_event)
    puts "^"*100
    puts raw_event
    # o = CaseNote.create!(content: raw_event, creator_id: 1)
    # puts "#########{o}"
    test = Oj.load raw_event
    test.execute
    # event_params = JSON.parse(raw_event)
    # SomeWiseService.build.call(event_params)
    ack!
  end
end

My profile

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker:  bundle exec rake jobs:work
sneaker: WORKERS=TestsWorker bundle exec rake sneakers:run

My rakefile

require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
require 'sneakers/tasks'

Test::Application.load_tasks

My sneaker configuration

require 'sneakers'
Sneakers.configure  amqp: ENV['RABBITMQ_BIGWIG_RX_URL'],
                    log: "log/sneakers.log",
                    threads: 1,
                    workers: 1

puts "configuring sneaker"

, . rabbitmq. . , .

sneakers.log on heroku:

# Logfile created on 2016-04-05 14:40:59 +0530 by logger.rb/41212
+4
1

. . , . , , .

- .

. pcc.commands pcc_cmd test.commands test_cmd.

test_cmd, ​​TestPublisher

x.publish(Test, :persistent => true, :routing_key => 'pcc_cmd')

(pcc.commands). , test.commands.

TestWorker

from_queue "test.commands", env: nil

, test.commands.

sneakers.log: sneakers.log . , , . log . :

require 'sneakers'
Sneakers.configure  amqp: ENV['RABBITMQ_BIGWIG_RX_URL'],
                  # log: "log/sneakers.log",
                  threads: 1,
                  workers: 1

, ( ) heroku, , heroku logs -a app_name --tail.

+1

All Articles