File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ # encoding: utf-8
3+
4+ require "bunny"
5+
6+ conn = Bunny . new
7+ conn . start
8+
9+ ch = conn . create_channel
10+ q = ch . queue ( "hello" )
11+
12+ puts "Will wait from messages in #{ q . name } "
13+ q . subscribe ( :block => true ) do |delivery_info , properties , body |
14+ puts " [x] Received #{ body } "
15+
16+ # cancel the consumer to exit
17+ delivery_info . consumer . cancel
18+ end
19+
20+ conn . close
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ # encoding: utf-8
3+
4+ require "bunny"
5+
6+ conn = Bunny . new
7+ conn . start
8+
9+ ch = conn . create_channel
10+ q = ch . queue ( "hello" )
11+
12+ ch . default_exchange . publish ( "Hello World!" , :routing_key => q . name )
13+ puts " [x] Sent 'Hello World!'"
14+
15+ sleep 0.5
16+ conn . close
You can’t perform that action at this time.
0 commit comments