Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ruby: receive.rb

  • Loading branch information...
commit 4f55a4fcbf7dd1ec19e75e194d981adbebf7c0fc 1 parent db237ac
@botanicus botanicus authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 ruby/receive.rb
View
21 ruby/receive.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.