Skip to content

Instantly share code, notes, and snippets.

@dsbraz
Created September 25, 2014 20:47
Show Gist options
  • Save dsbraz/45dd1766e0926441b294 to your computer and use it in GitHub Desktop.
Save dsbraz/45dd1766e0926441b294 to your computer and use it in GitHub Desktop.
require 'eventmachine'
require 'redis'
require 'amqp'
EventMachine.run do
EventMachine.start_server '127.0.0.1', 8080 do |c|
def c.receive_data(data)
redis = Redis.new
connection = AMQP.connect(:host => '127.0.0.1')
channel = AMQP::Channel.new(connection)
queue = channel.queue("br.rsk", :auto_delete => true)
exchange = channel.direct("")
p data
10.times do |i|
p redis.get("key_#{i}")
end
exchange.publish "Hello, world!", :routing_key => queue.name
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment