Skip to content

Commit 6465bd1

Browse files
author
Jakub Stastny aka botanicus
committed
Example emit_log in Ruby.
1 parent 228b850 commit 6465bd1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ruby/emit_log.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
exchange = channel.fanout("logs")
9+
message = (ARGV[1..-1] || ["info: Hello World!"]).join(" ")
10+
11+
exchange.publish(message)
12+
puts " [x] Sent #{message}"
13+
14+
EM.add_timer(0.5) do
15+
connection.close do
16+
EM.stop { exit }
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)