We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3ef59c7 commit 68d4d5bCopy full SHA for 68d4d5b
ruby/receive.rb
@@ -9,12 +9,13 @@
9
ch = conn.create_channel
10
q = ch.queue("hello")
11
12
-puts " [*] Waiting for messages in #{q.name}. To exit press CTRL+C"
13
-q.subscribe(:block => true) do |delivery_info, properties, body|
14
- puts " [x] Received #{body}"
+begin
+ puts " [*] Waiting for messages in #{q.name}. To exit press CTRL+C"
+ q.subscribe(:block => true) do |delivery_info, properties, body|
15
+ puts " [x] Received #{body}"
16
+ end
17
+rescue Interrupt => _
18
+ puts " [x] Shutting down..."
19
- # cancel the consumer to exit
- delivery_info.consumer.cancel
20
+ conn.close
21
end
-
-conn.close
0 commit comments