Skip to content

Instantly share code, notes, and snippets.

@krishna-shilpakar
Last active August 29, 2015 13:57
Show Gist options
  • Save krishna-shilpakar/9736416 to your computer and use it in GitHub Desktop.
Save krishna-shilpakar/9736416 to your computer and use it in GitHub Desktop.
require "amqp"
EventMachine.run do
connection = AMQP.connect
channel = AMQP::Channel.new(connection)
replies_queue = channel.queue("citizen40.install.app.acknowledge", :exclusive => true, :auto_delete => true)
replies_queue.subscribe do |metadata, payload|
puts "[response] Response for #{metadata.correlation_id}: #{payload.inspect}"
# if payload[:success] == true
connection.close { EventMachine.stop }
# end
end
# request time from a peer every 3 seconds
puts "[request] Sending a request to install softwar..."
payload = {:app => 'ftp}.to_yaml
channel.default_exchange.publish(payload, :routing_key => "citizen40.install.app")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment