I have a RabbitMQ with bunny working using consumer.rb and publisher.rb. If I run
ruby consumer.rb
and then
publisher.rb
I get data being published (data coming from another class). Data prints like this on ruby consumer.rb when I run publisher.rb:
Test New Data
1142.5186392493372
I need these two scripts run constantly so publisher keep pushing the data (@devise.value) through and i see the above output continuously. I have tried making a new server file using Daemon and run ruby server.rb start. But this does keep running publisher.rb but not constantly so it publishes the data. Also how can I make this RabbitMQ ruby app publish data to another web based rails app?
publisher.rb
require 'bunny' require 'daemons'
class BunnyPublisher
def connection
conn = Bunny.new
conn.start
end
def channel
connection.create_channel
end
def q
channel.queue("que")
end
def exchange
channel.default_exchange
end
def publish(data, q)
exchange.publish(data, routing_key: "que")
sleep(5)
connection.close
end
server.rb
require 'daemons'
Daemons.run('publisher.rb')
Thanks