Skip to content

Commit 95bdddb

Browse files
author
Michael Klishin
committed
Make sure Bunny tutorials produce the same output as Pika
1 parent 7530b3f commit 95bdddb

File tree

9 files changed

+14
-30
lines changed

9 files changed

+14
-30
lines changed

ruby/emit_log.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
msg = ARGV.empty? ? "Hello World!" : ARGV.join(" ")
1313

1414
x.publish(msg)
15-
puts " [x] Sent '#{msg}'"
15+
puts " [x] Sent #{msg}"
1616

1717
sleep 0.5
1818
conn.close

ruby/new_task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
msg = ARGV.empty? ? "Hello World!" : ARGV.join(" ")
1313

1414
q.publish(msg, :persistent => true)
15-
puts " [x] Published #{msg}"
15+
puts " [x] Sent #{msg}"
1616

1717
sleep 1.0
1818
conn.close

ruby/receive.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
q = ch.queue("hello")
1111

1212
begin
13-
puts " [*] Waiting for messages in #{q.name}. To exit press CTRL+C"
13+
puts " [*] Waiting for messages. To exit press CTRL+C"
1414
q.subscribe(:block => true) do |delivery_info, properties, body|
1515
puts " [x] Received #{body}"
1616
end
1717
rescue Interrupt => _
18-
puts " [x] Shutting down..."
19-
2018
conn.close
2119
end

ruby/receive_logs.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
puts " [x] #{body}"
2020
end
2121
rescue Interrupt => _
22-
puts " [*] Shutting down..."
23-
2422
ch.close
2523
conn.close
2624
end

ruby/receive_logs_direct.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222

2323
begin
2424
q.subscribe(:block => true) do |delivery_info, properties, body|
25-
puts " [x] #{body}"
25+
puts " [x] #{delivery_info.routing_key}:#{body}"
2626
end
2727
rescue Interrupt => _
28-
puts " [*] Shutting down..."
29-
3028
ch.close
3129
conn.close
3230
end

ruby/receive_logs_topic.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
puts " [x] #{delivery_info.routing_key}:#{body}"
2626
end
2727
rescue Interrupt => _
28-
puts " [*] Shutting down..."
29-
3028
ch.close
3129
conn.close
3230
end

ruby/rpc_client.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,10 @@ def generate_uuid
4949
end
5050

5151

52-
begin
53-
client = FibonacciClient.new(ch, "rpc_queue")
54-
puts " [x] Requesting fib(30). Collecting replies from #{client.reply_queue.name}"
55-
response = client.call(30)
56-
puts " [.] Got #{response}"
57-
rescue Interrupt => _
58-
puts " [*] Shutting down..."
59-
60-
ch.close
61-
conn.close
62-
end
52+
client = FibonacciClient.new(ch, "rpc_queue")
53+
puts " [x] Requesting fib(30)"
54+
response = client.call(30)
55+
puts " [.] Got #{response}"
56+
57+
ch.close
58+
conn.close

ruby/rpc_server.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def start(queue_name)
2222
n = payload.to_i
2323
r = self.class.fib(n)
2424

25-
puts " [*] Serving a request: #{n} => #{r}. Replying to #{properties.reply_to}"
26-
2725
@x.publish(r.to_s, :routing_key => properties.reply_to, :correlation_id => properties.correlation_id)
2826
end
2927
end
@@ -41,11 +39,9 @@ def self.fib(n)
4139

4240
begin
4341
server = FibonacciServer.new(ch)
44-
puts " [*] Waiting for requests..."
42+
" [x] Awaiting RPC requests"
4543
server.start("rpc_queue")
4644
rescue Interrupt => _
47-
puts " [*] Shutting down..."
48-
4945
ch.close
5046
conn.close
5147
end

ruby/worker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
puts " [x] Received '#{body}'"
1818
# imitate some work
1919
sleep 1.0
20-
20+
puts " [x] Done"
2121
ch.ack(delivery_info.delivery_tag)
2222
end
2323
rescue Interrupt => _
24-
puts " [*] Shutting down..."
24+
conn.close
2525
end

0 commit comments

Comments
 (0)