Permalink
Browse files

Ruby: receive.rb

  • Loading branch information...
1 parent db237ac commit 4f55a4fcbf7dd1ec19e75e194d981adbebf7c0fc @botanicus botanicus committed May 3, 2011
Showing with 21 additions and 0 deletions.
  1. +21 −0 ruby/receive.rb
View
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+# encoding: utf-8
+
+require "amqp"
+
+AMQP.start(:host => "localhost") do |connection|
+ channel = AMQP::Channel.new(connection)
+ queue = channel.queue("hello")
+
+ Signal.trap("INT") do
+ connection.close do
+ EM.stop { exit }
+ end
+ end
+
+ puts " [*] Waiting for messages. To exit press CTRL+C"
+
+ queue.subscribe do |body|
+ puts " [x] Received #{body}"
+ end
+end

0 comments on commit 4f55a4f

Please sign in to comment.