Skip to content

Commit 4f55a4f

Browse files
author
Jakub Stastny aka botanicus
committed
Ruby: receive.rb
1 parent db237ac commit 4f55a4f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

ruby/receive.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env ruby
2+
# encoding: utf-8
3+
4+
require "amqp"
5+
6+
AMQP.start(:host => "localhost") do |connection|
7+
channel = AMQP::Channel.new(connection)
8+
queue = channel.queue("hello")
9+
10+
Signal.trap("INT") do
11+
connection.close do
12+
EM.stop { exit }
13+
end
14+
end
15+
16+
puts " [*] Waiting for messages. To exit press CTRL+C"
17+
18+
queue.subscribe do |body|
19+
puts " [x] Received #{body}"
20+
end
21+
end

0 commit comments

Comments
 (0)