bunny 0.8.0 → 0.9.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +7 -1
  2. data/.travis.yml +14 -4
  3. data/ChangeLog.md +72 -0
  4. data/Gemfile +17 -11
  5. data/README.md +82 -0
  6. data/bunny.gemspec +6 -13
  7. data/examples/connection/heartbeat.rb +17 -0
  8. data/lib/bunny.rb +40 -56
  9. data/lib/bunny/channel.rb +615 -19
  10. data/lib/bunny/channel_id_allocator.rb +59 -0
  11. data/lib/bunny/compatibility.rb +24 -0
  12. data/lib/bunny/concurrent/condition.rb +63 -0
  13. data/lib/bunny/consumer.rb +42 -26
  14. data/lib/bunny/consumer_tag_generator.rb +22 -0
  15. data/lib/bunny/consumer_work_pool.rb +67 -0
  16. data/lib/bunny/exceptions.rb +128 -0
  17. data/lib/bunny/exchange.rb +131 -136
  18. data/lib/bunny/framing.rb +53 -0
  19. data/lib/bunny/heartbeat_sender.rb +59 -0
  20. data/lib/bunny/main_loop.rb +70 -0
  21. data/lib/bunny/message_metadata.rb +126 -0
  22. data/lib/bunny/queue.rb +102 -275
  23. data/lib/bunny/session.rb +478 -0
  24. data/lib/bunny/socket.rb +44 -0
  25. data/lib/bunny/system_timer.rb +9 -9
  26. data/lib/bunny/transport.rb +179 -0
  27. data/lib/bunny/version.rb +1 -1
  28. data/spec/compatibility/queue_declare_spec.rb +40 -0
  29. data/spec/higher_level_api/integration/basic_ack_spec.rb +54 -0
  30. data/spec/higher_level_api/integration/basic_consume_spec.rb +51 -0
  31. data/spec/higher_level_api/integration/basic_get_spec.rb +47 -0
  32. data/spec/higher_level_api/integration/basic_nack_spec.rb +39 -0
  33. data/spec/higher_level_api/integration/basic_publish_spec.rb +105 -0
  34. data/spec/higher_level_api/integration/basic_qos_spec.rb +32 -0
  35. data/spec/higher_level_api/integration/basic_recover_spec.rb +18 -0
  36. data/spec/higher_level_api/integration/basic_reject_spec.rb +53 -0
  37. data/spec/higher_level_api/integration/basic_return_spec.rb +33 -0
  38. data/spec/higher_level_api/integration/channel_close_spec.rb +29 -0
  39. data/spec/higher_level_api/integration/channel_flow_spec.rb +24 -0
  40. data/spec/higher_level_api/integration/channel_open_spec.rb +57 -0
  41. data/spec/higher_level_api/integration/channel_open_stress_spec.rb +22 -0
  42. data/spec/higher_level_api/integration/confirm_select_spec.rb +19 -0
  43. data/spec/higher_level_api/integration/connection_spec.rb +340 -0
  44. data/spec/higher_level_api/integration/exchange_bind_spec.rb +31 -0
  45. data/spec/higher_level_api/integration/exchange_declare_spec.rb +183 -0
  46. data/spec/higher_level_api/integration/exchange_delete_spec.rb +37 -0
  47. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +40 -0
  48. data/spec/higher_level_api/integration/queue_bind_spec.rb +109 -0
  49. data/spec/higher_level_api/integration/queue_declare_spec.rb +129 -0
  50. data/spec/higher_level_api/integration/queue_delete_spec.rb +38 -0
  51. data/spec/higher_level_api/integration/queue_purge_spec.rb +30 -0
  52. data/spec/higher_level_api/integration/queue_unbind_spec.rb +33 -0
  53. data/spec/higher_level_api/integration/tx_commit_spec.rb +21 -0
  54. data/spec/higher_level_api/integration/tx_rollback_spec.rb +21 -0
  55. data/spec/lower_level_api/integration/basic_cancel_spec.rb +57 -0
  56. data/spec/lower_level_api/integration/basic_consume_spec.rb +100 -0
  57. data/spec/spec_helper.rb +64 -0
  58. data/spec/unit/bunny_spec.rb +15 -0
  59. data/spec/unit/concurrent/condition_spec.rb +66 -0
  60. metadata +135 -93
  61. data/CHANGELOG +0 -21
  62. data/README.textile +0 -76
  63. data/Rakefile +0 -14
  64. data/examples/simple.rb +0 -32
  65. data/examples/simple_ack.rb +0 -35
  66. data/examples/simple_consumer.rb +0 -55
  67. data/examples/simple_fanout.rb +0 -41
  68. data/examples/simple_headers.rb +0 -42
  69. data/examples/simple_publisher.rb +0 -29
  70. data/examples/simple_topic.rb +0 -61
  71. data/ext/amqp-0.9.1.json +0 -389
  72. data/ext/config.yml +0 -4
  73. data/ext/qparser.rb +0 -426
  74. data/lib/bunny/client.rb +0 -370
  75. data/lib/bunny/subscription.rb +0 -92
  76. data/lib/qrack/amq-client-url.rb +0 -165
  77. data/lib/qrack/channel.rb +0 -20
  78. data/lib/qrack/client.rb +0 -247
  79. data/lib/qrack/errors.rb +0 -5
  80. data/lib/qrack/protocol/protocol.rb +0 -135
  81. data/lib/qrack/protocol/spec.rb +0 -525
  82. data/lib/qrack/qrack.rb +0 -20
  83. data/lib/qrack/queue.rb +0 -40
  84. data/lib/qrack/subscription.rb +0 -152
  85. data/lib/qrack/transport/buffer.rb +0 -305
  86. data/lib/qrack/transport/frame.rb +0 -102
  87. data/spec/spec_09/amqp_url_spec.rb +0 -19
  88. data/spec/spec_09/bunny_spec.rb +0 -76
  89. data/spec/spec_09/connection_spec.rb +0 -34
  90. data/spec/spec_09/exchange_spec.rb +0 -173
  91. data/spec/spec_09/queue_spec.rb +0 -240
metadata CHANGED
@@ -1,124 +1,166 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
5
- prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
4
+ prerelease: 6
5
+ version: 0.9.0.pre1
11
6
  platform: ruby
12
7
  authors:
13
- - Chris Duncan
14
- - Eric Lindvall
15
- - Jakub Stastny aka botanicus
16
- - Michael S. Klishin
17
- - Stefan Kaes
8
+ - Chris Duncan
9
+ - Eric Lindvall
10
+ - Jakub Stastny aka botanicus
11
+ - Michael S. Klishin
12
+ - Stefan Kaes
18
13
  autorequire:
19
14
  bindir: bin
20
15
  cert_chain: []
21
16
 
22
- date: 2012-06-23 00:00:00 Z
23
- dependencies: []
24
-
25
- description: A synchronous Ruby AMQP client that enables interaction with AMQP-compliant brokers.
17
+ date: 2012-11-27 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: amq-protocol
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.0.0
28
+ type: :runtime
29
+ version_requirements: *id001
30
+ description: Easy to use synchronous Ruby client for RabbitMQ
26
31
  email:
27
- - celldee@gmail.com
28
- - eric@5stops.com
29
- - stastny@101ideas.cz
30
- - michael@novemberain.com
31
- - skaes@railsexpress.de
32
+ - celldee@gmail.com
33
+ - eric@5stops.com
34
+ - stastny@101ideas.cz
35
+ - michael@novemberain.com
36
+ - skaes@railsexpress.de
32
37
  executables: []
33
38
 
34
39
  extensions: []
35
40
 
36
41
  extra_rdoc_files:
37
- - README.textile
42
+ - README.md
38
43
  files:
39
- - .gitignore
40
- - .rspec
41
- - .travis.yml
42
- - .yardopts
43
- - CHANGELOG
44
- - Gemfile
45
- - LICENSE
46
- - README.textile
47
- - Rakefile
48
- - bunny.gemspec
49
- - examples/simple.rb
50
- - examples/simple_ack.rb
51
- - examples/simple_consumer.rb
52
- - examples/simple_fanout.rb
53
- - examples/simple_headers.rb
54
- - examples/simple_publisher.rb
55
- - examples/simple_topic.rb
56
- - ext/amqp-0.9.1.json
57
- - ext/config.yml
58
- - ext/qparser.rb
59
- - lib/bunny.rb
60
- - lib/bunny/channel.rb
61
- - lib/bunny/client.rb
62
- - lib/bunny/consumer.rb
63
- - lib/bunny/exchange.rb
64
- - lib/bunny/queue.rb
65
- - lib/bunny/subscription.rb
66
- - lib/bunny/system_timer.rb
67
- - lib/bunny/version.rb
68
- - lib/qrack/amq-client-url.rb
69
- - lib/qrack/channel.rb
70
- - lib/qrack/client.rb
71
- - lib/qrack/errors.rb
72
- - lib/qrack/protocol/protocol.rb
73
- - lib/qrack/protocol/spec.rb
74
- - lib/qrack/qrack.rb
75
- - lib/qrack/queue.rb
76
- - lib/qrack/subscription.rb
77
- - lib/qrack/transport/buffer.rb
78
- - lib/qrack/transport/frame.rb
79
- - spec/spec_09/amqp_url_spec.rb
80
- - spec/spec_09/bunny_spec.rb
81
- - spec/spec_09/connection_spec.rb
82
- - spec/spec_09/exchange_spec.rb
83
- - spec/spec_09/queue_spec.rb
44
+ - .gitignore
45
+ - .rspec
46
+ - .travis.yml
47
+ - .yardopts
48
+ - ChangeLog.md
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - bin/ci/before_build.sh
53
+ - bunny.gemspec
54
+ - examples/connection/heartbeat.rb
55
+ - lib/bunny.rb
56
+ - lib/bunny/channel.rb
57
+ - lib/bunny/channel_id_allocator.rb
58
+ - lib/bunny/compatibility.rb
59
+ - lib/bunny/concurrent/condition.rb
60
+ - lib/bunny/consumer.rb
61
+ - lib/bunny/consumer_tag_generator.rb
62
+ - lib/bunny/consumer_work_pool.rb
63
+ - lib/bunny/exceptions.rb
64
+ - lib/bunny/exchange.rb
65
+ - lib/bunny/framing.rb
66
+ - lib/bunny/heartbeat_sender.rb
67
+ - lib/bunny/main_loop.rb
68
+ - lib/bunny/message_metadata.rb
69
+ - lib/bunny/queue.rb
70
+ - lib/bunny/session.rb
71
+ - lib/bunny/socket.rb
72
+ - lib/bunny/system_timer.rb
73
+ - lib/bunny/transport.rb
74
+ - lib/bunny/version.rb
75
+ - spec/compatibility/queue_declare_spec.rb
76
+ - spec/higher_level_api/integration/basic_ack_spec.rb
77
+ - spec/higher_level_api/integration/basic_consume_spec.rb
78
+ - spec/higher_level_api/integration/basic_get_spec.rb
79
+ - spec/higher_level_api/integration/basic_nack_spec.rb
80
+ - spec/higher_level_api/integration/basic_publish_spec.rb
81
+ - spec/higher_level_api/integration/basic_qos_spec.rb
82
+ - spec/higher_level_api/integration/basic_recover_spec.rb
83
+ - spec/higher_level_api/integration/basic_reject_spec.rb
84
+ - spec/higher_level_api/integration/basic_return_spec.rb
85
+ - spec/higher_level_api/integration/channel_close_spec.rb
86
+ - spec/higher_level_api/integration/channel_flow_spec.rb
87
+ - spec/higher_level_api/integration/channel_open_spec.rb
88
+ - spec/higher_level_api/integration/channel_open_stress_spec.rb
89
+ - spec/higher_level_api/integration/confirm_select_spec.rb
90
+ - spec/higher_level_api/integration/connection_spec.rb
91
+ - spec/higher_level_api/integration/exchange_bind_spec.rb
92
+ - spec/higher_level_api/integration/exchange_declare_spec.rb
93
+ - spec/higher_level_api/integration/exchange_delete_spec.rb
94
+ - spec/higher_level_api/integration/exchange_unbind_spec.rb
95
+ - spec/higher_level_api/integration/queue_bind_spec.rb
96
+ - spec/higher_level_api/integration/queue_declare_spec.rb
97
+ - spec/higher_level_api/integration/queue_delete_spec.rb
98
+ - spec/higher_level_api/integration/queue_purge_spec.rb
99
+ - spec/higher_level_api/integration/queue_unbind_spec.rb
100
+ - spec/higher_level_api/integration/tx_commit_spec.rb
101
+ - spec/higher_level_api/integration/tx_rollback_spec.rb
102
+ - spec/lower_level_api/integration/basic_cancel_spec.rb
103
+ - spec/lower_level_api/integration/basic_consume_spec.rb
104
+ - spec/spec_helper.rb
105
+ - spec/unit/bunny_spec.rb
106
+ - spec/unit/concurrent/condition_spec.rb
84
107
  homepage: http://github.com/ruby-amqp/bunny
85
108
  licenses: []
86
109
 
87
- post_install_message: "[\e[32mVersion 0.8.0\e[0m] AMQP 0.8 client is removed. Bunny is an AMQP 0.9.1 client only now.\n"
88
- rdoc_options:
89
- - --main
90
- - README.rdoc
110
+ post_install_message:
111
+ rdoc_options: []
112
+
91
113
  require_paths:
92
- - lib
114
+ - lib
93
115
  required_ruby_version: !ruby/object:Gem::Requirement
94
116
  none: false
95
117
  requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: "0"
102
121
  required_rubygems_version: !ruby/object:Gem::Requirement
103
122
  none: false
104
123
  requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 3
108
- segments:
109
- - 0
110
- version: "0"
124
+ - - ">"
125
+ - !ruby/object:Gem::Version
126
+ version: 1.3.1
111
127
  requirements: []
112
128
 
113
- rubyforge_project: bunny-amqp
114
- rubygems_version: 1.8.15
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.24
115
131
  signing_key:
116
132
  specification_version: 3
117
- summary: Synchronous Ruby AMQP 0.8.0 client
133
+ summary: Easy to use synchronous Ruby client for RabbitMQ
118
134
  test_files:
119
- - spec/spec_09/amqp_url_spec.rb
120
- - spec/spec_09/bunny_spec.rb
121
- - spec/spec_09/connection_spec.rb
122
- - spec/spec_09/exchange_spec.rb
123
- - spec/spec_09/queue_spec.rb
124
- has_rdoc: true
135
+ - spec/compatibility/queue_declare_spec.rb
136
+ - spec/higher_level_api/integration/basic_ack_spec.rb
137
+ - spec/higher_level_api/integration/basic_consume_spec.rb
138
+ - spec/higher_level_api/integration/basic_get_spec.rb
139
+ - spec/higher_level_api/integration/basic_nack_spec.rb
140
+ - spec/higher_level_api/integration/basic_publish_spec.rb
141
+ - spec/higher_level_api/integration/basic_qos_spec.rb
142
+ - spec/higher_level_api/integration/basic_recover_spec.rb
143
+ - spec/higher_level_api/integration/basic_reject_spec.rb
144
+ - spec/higher_level_api/integration/basic_return_spec.rb
145
+ - spec/higher_level_api/integration/channel_close_spec.rb
146
+ - spec/higher_level_api/integration/channel_flow_spec.rb
147
+ - spec/higher_level_api/integration/channel_open_spec.rb
148
+ - spec/higher_level_api/integration/channel_open_stress_spec.rb
149
+ - spec/higher_level_api/integration/confirm_select_spec.rb
150
+ - spec/higher_level_api/integration/connection_spec.rb
151
+ - spec/higher_level_api/integration/exchange_bind_spec.rb
152
+ - spec/higher_level_api/integration/exchange_declare_spec.rb
153
+ - spec/higher_level_api/integration/exchange_delete_spec.rb
154
+ - spec/higher_level_api/integration/exchange_unbind_spec.rb
155
+ - spec/higher_level_api/integration/queue_bind_spec.rb
156
+ - spec/higher_level_api/integration/queue_declare_spec.rb
157
+ - spec/higher_level_api/integration/queue_delete_spec.rb
158
+ - spec/higher_level_api/integration/queue_purge_spec.rb
159
+ - spec/higher_level_api/integration/queue_unbind_spec.rb
160
+ - spec/higher_level_api/integration/tx_commit_spec.rb
161
+ - spec/higher_level_api/integration/tx_rollback_spec.rb
162
+ - spec/lower_level_api/integration/basic_cancel_spec.rb
163
+ - spec/lower_level_api/integration/basic_consume_spec.rb
164
+ - spec/spec_helper.rb
165
+ - spec/unit/bunny_spec.rb
166
+ - spec/unit/concurrent/condition_spec.rb
data/CHANGELOG DELETED
@@ -1,21 +0,0 @@
1
- = Version 0.8.0
2
-
3
- * AMQP 0.8 client is removed. Bunny is an AMQP 0.9.1 client only now.
4
-
5
-
6
- = Version 0.7.3
7
-
8
- * AMQP connection URI parser now respects port
9
-
10
- = Version 0.7.2
11
-
12
- * Fixes for irb tab completion
13
-
14
- = Version 0.7.0
15
-
16
- * Added :content_type option to Exchange#publish
17
- * Lots of minor fixes
18
-
19
- = Version 0.6.3
20
- * Encoding of source files is set to UTF-8 on Ruby 1.9.
21
- * Queue#publish deprecated.
@@ -1,76 +0,0 @@
1
- h1. About bunny
2
-
3
- Bunny is a synchronous "AMQP 0.8.0":http://bit.ly/amqp-model-explained client. It supports Ruby 1.9.2, 1.8.7, Ruby Enterprise Edition and JRuby. Protocol-wise, Bunny supports AMQP 0.9.1 and 0.8. Support for AMQP 0.8 will be dropped in the next version of Bunny (0.8) because most of popular AMQP brokers such as RabbitMQ have already stopped or are planning to stop supporting it in the near future.
4
-
5
- h2. Limited Functionality Disclaimer
6
-
7
- Bunny is very simplistic and does not support many features
8
-
9
- You can use Bunny to:
10
-
11
- * Create and delete exchanges
12
- * Create and delete queues
13
- * Publish and synchronously consume (basic.get) messages
14
-
15
- But it does not support
16
-
17
- * Arrays, hashes or even symbols in message headers
18
- * Framing of large messages
19
- * Many AMQP operations
20
- * RabbitMQ extensions
21
- * AMQP 0.9.1-only brokers
22
-
23
- h2. Bunny is NOT actively maintained
24
-
25
- Bunny is also **not actively maintained**. Consider using Hot Bunnies (JRuby) or amqp gem instead.
26
-
27
-
28
- h2. Quick Start
29
-
30
- <pre>
31
- require "bunny"
32
-
33
- b = Bunny.new(:logging => true)
34
-
35
- # start a communication session with the amqp server
36
- b.start
37
-
38
- # declare a queue
39
- q = b.queue("test1")
40
-
41
- # declare default direct exchange which is bound to all queues
42
- e = b.exchange("")
43
-
44
- # publish a message to the exchange which then gets routed to the queue
45
- e.publish("Hello, everybody!", :key => 'test1')
46
-
47
- # get message from the queue
48
- msg = q.pop[:payload]
49
-
50
- puts "This is the message: " + msg + "\n\n"
51
-
52
- # close the connection
53
- b.stop
54
- </pre>
55
-
56
- ... or just:
57
-
58
- <pre>
59
- require "bunny"
60
-
61
- # Create a direct queue named "my_testq"
62
- Bunny.run { |c| c.queue("my_testq") }
63
- </pre>
64
-
65
- Please see the @examples@ directory for additional usage information.
66
-
67
- h2. AMQP Resources
68
-
69
- * "AMQP 0.9.1 model explained":http://bit.ly/amqp-model-explained - Introductory explanation of the AMQP v0.9.1 specification with particular reference to RabbitMQ
70
-
71
- h2. Links
72
-
73
- * "Source code":http://github.com/ruby-amqp/bunny
74
- * "Follow @rubyamqp":http://twitter.com/rubyamqp on Twitter
75
- * "Ruby AMQP Google Group":http://groups.google.com/group/ruby-amqp
76
- * "Blog":http://bunnyamqp.wordpress.com
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "bundler/gem_tasks"
4
-
5
- desc "Run AMQP rspec tests"
6
- task :spec do
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new("spec") do |t|
9
- t.pattern = "spec/spec_09/*_spec.rb"
10
- t.rspec_opts = ['--color']
11
- end
12
- end
13
-
14
- task :default => [ :spec ]
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # simple.rb
4
-
5
- # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
6
- # and that it is running on 'localhost'.
7
-
8
- # If this is not the case, please change the 'Bunny.new' call below to include
9
- # the relevant arguments e.g. b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
10
-
11
- $:.unshift File.dirname(__FILE__) + '/../lib'
12
-
13
- require 'bunny'
14
-
15
- b = Bunny.new(:logging => true)
16
-
17
- # start a communication session with the amqp server
18
- b.start
19
-
20
- # declare a queue
21
- q = b.queue('test1')
22
-
23
- # publish a message to the queue
24
- q.publish('➸ Hello everybody ☺!')
25
-
26
- # get message from the queue
27
- msg = q.pop[:payload]
28
-
29
- puts 'This is the message: ' + msg + "\n\n"
30
-
31
- # close the client connection
32
- b.stop
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # simple_ack.rb
4
-
5
- # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
6
- # and that it is running on 'localhost'.
7
-
8
- # If this is not the case, please change the 'Bunny.new' call below to include
9
- # the relevant arguments e.g. b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
10
-
11
- $:.unshift File.dirname(__FILE__) + '/../lib'
12
-
13
- require 'bunny'
14
-
15
- b = Bunny.new(:logging => true)
16
-
17
- # start a communication session with the amqp server
18
- b.start
19
-
20
- # declare a queue
21
- q = b.queue('test1')
22
-
23
- # publish a message to the queue
24
- q.publish('Testing acknowledgements')
25
-
26
- # get message from the queue
27
- msg = q.pop(:ack => true)[:payload]
28
-
29
- # acknowledge receipt of message
30
- q.ack
31
-
32
- puts 'This is the message: ' + msg + "\n\n"
33
-
34
- # close the client connection
35
- b.stop
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # simple_consumer.rb
4
-
5
- # N.B. To be used in conjunction with simple_publisher.rb
6
-
7
- # Assumes that target message broker/server has a user called 'guest' with a password 'guest'
8
- # and that it is running on 'localhost'.
9
-
10
- # If this is not the case, please change the 'Bunny.new' call below to include
11
- # the relevant arguments e.g. b = Bunny.new(:user => 'john', :pass => 'doe', :host => 'foobar')
12
-
13
- # How this example works
14
- #=======================
15
- #
16
- # Open up two console windows start this program in one of them by typing -
17
- #
18
- # ruby simple_consumer.rb
19
- #
20
- # Then switch to the other console window and type -
21
- #
22
- # ruby simple_publisher.rb
23
- #
24
- # A message will be printed out by the simple_consumer and it will wait for the next message
25
- # until the timeout interval is reached.
26
- #
27
- # Run simple_publisher as many times as you like. When you want the program to stop just stop
28
- # sending messages and the subscribe loop will timeout after 30 seconds, the program will
29
- # unsubscribe from the queue and close the connection to the server.
30
-
31
- $:.unshift File.dirname(__FILE__) + '/../lib'
32
-
33
- require 'bunny'
34
-
35
- b = Bunny.new(:logging => true)
36
-
37
- # start a communication session with the amqp server
38
- b.start
39
-
40
- # create/get queue
41
- q = b.queue('po_box')
42
-
43
- # create/get exchange
44
- exch = b.exchange('sorting_room')
45
-
46
- # bind queue to exchange
47
- q.bind(exch, :key => 'fred')
48
-
49
- # subscribe to queue
50
- q.subscribe(:consumer_tag => 'testtag1', :timeout => 30) do |msg|
51
- puts "#{q.default_consumer.message_count}: #{msg[:payload]}"
52
- end
53
-
54
- # Close client
55
- b.stop