First of all this is working fine in my local machine.
I have one publisher app (Rails 3), which is publishing message to cloudamq(addon) in heroku, we are getting messages in cloudamq
and one consumer application (Rails 5) which is also running on heroku as a separate app, i put this consumer in a rake task but here the issue is this takes messages from the queue only when we restart the server, that means this rake task will run when we restart, but in rabbitMQ it shows always running
So how can we make the consumer to listen continuously once we push to heroku?
Also once we get the message from queue i have to call a sidekiq worker, that is not happening? using 'redis to go' addon
CONSUMER APP
Gem which i have used in this cosumer application
gem 'redis', '~> 3.0'
gem 'sidekiq'
gem 'bunny'
This is the consumer part to get the message from queue as a rake task.
task :do_consumer => :environment do
connection = Bunny.new(ENV['CLOUDAMQP_URL'])
connection.start # start a communication session with the amqp server
channel = connection.channel()
queue = channel.queue('order-queue', durable: true)
puts ' [*] Waiting for messages. To exit press CTRL+C'
queue.subscribe(manual_ack: true, block: true) do |delivery_info,
properties, payload|
puts " [x] Received #{payload}"
puts " [x] Done"
channel.ack(delivery_info.delivery_tag, false)
# Call sidekiq worker to do task
callSidekiqWorker.perform_async(payload)
end
end
Procfile
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -e production
worker: bundle exec rake do_consumer