bunny 1.0.7 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +92 -87
  3. data/lib/amq/protocol/extensions.rb +2 -0
  4. data/lib/bunny/authentication/credentials_encoder.rb +2 -0
  5. data/lib/bunny/authentication/external_mechanism_encoder.rb +2 -0
  6. data/lib/bunny/authentication/plain_mechanism_encoder.rb +2 -0
  7. data/lib/bunny/channel.rb +485 -186
  8. data/lib/bunny/channel_id_allocator.rb +8 -4
  9. data/lib/bunny/concurrent/atomic_fixnum.rb +2 -0
  10. data/lib/bunny/concurrent/condition.rb +2 -0
  11. data/lib/bunny/concurrent/continuation_queue.rb +37 -13
  12. data/lib/bunny/concurrent/synchronized_sorted_set.rb +2 -0
  13. data/lib/bunny/consumer.rb +20 -13
  14. data/lib/bunny/consumer_tag_generator.rb +6 -2
  15. data/lib/bunny/consumer_work_pool.rb +37 -7
  16. data/lib/bunny/cruby/socket.rb +51 -22
  17. data/lib/bunny/cruby/ssl_socket.rb +68 -5
  18. data/lib/bunny/delivery_info.rb +3 -1
  19. data/lib/bunny/exceptions.rb +27 -4
  20. data/lib/bunny/exchange.rb +35 -29
  21. data/lib/bunny/framing.rb +2 -0
  22. data/lib/bunny/get_response.rb +85 -0
  23. data/lib/bunny/heartbeat_sender.rb +9 -6
  24. data/lib/bunny/message_properties.rb +2 -0
  25. data/lib/bunny/queue.rb +89 -41
  26. data/lib/bunny/reader_loop.rb +72 -28
  27. data/lib/bunny/return_info.rb +2 -0
  28. data/lib/bunny/session.rb +621 -225
  29. data/lib/bunny/socket.rb +7 -12
  30. data/lib/bunny/ssl_socket.rb +7 -12
  31. data/lib/bunny/test_kit.rb +15 -0
  32. data/lib/bunny/timeout.rb +3 -12
  33. data/lib/bunny/timestamp.rb +24 -0
  34. data/lib/bunny/transport.rb +223 -98
  35. data/lib/bunny/version.rb +2 -1
  36. data/lib/bunny/versioned_delivery_tag.rb +2 -0
  37. data/lib/bunny.rb +54 -8
  38. metadata +38 -224
  39. data/.gitignore +0 -22
  40. data/.rspec +0 -3
  41. data/.ruby-version +0 -1
  42. data/.travis.yml +0 -23
  43. data/.yardopts +0 -8
  44. data/ChangeLog.md +0 -1092
  45. data/Gemfile +0 -54
  46. data/LICENSE +0 -21
  47. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  48. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  49. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  50. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  51. data/benchmarks/channel_open.rb +0 -28
  52. data/benchmarks/mutex_and_monitor.rb +0 -42
  53. data/benchmarks/queue_declare.rb +0 -29
  54. data/benchmarks/queue_declare_and_bind.rb +0 -29
  55. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  56. data/benchmarks/synchronized_sorted_set.rb +0 -53
  57. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  58. data/bin/ci/before_build.sh +0 -31
  59. data/bunny.gemspec +0 -40
  60. data/examples/connection/authentication_failure.rb +0 -16
  61. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  62. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  63. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  64. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  65. data/examples/connection/channel_level_exception.rb +0 -35
  66. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  67. data/examples/connection/heartbeat.rb +0 -17
  68. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  69. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  70. data/examples/connection/unknown_host.rb +0 -16
  71. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  72. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  73. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  74. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  75. data/examples/guides/extensions/alternate_exchange.rb +0 -28
  76. data/examples/guides/extensions/basic_nack.rb +0 -33
  77. data/examples/guides/extensions/connection_blocked.rb +0 -35
  78. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  79. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  80. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  81. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  82. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  83. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  84. data/examples/guides/extensions/queue_lease.rb +0 -26
  85. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  86. data/examples/guides/getting_started/blabbr.rb +0 -27
  87. data/examples/guides/getting_started/hello_world.rb +0 -20
  88. data/examples/guides/getting_started/weathr.rb +0 -47
  89. data/examples/guides/queues/one_off_consumer.rb +0 -23
  90. data/examples/guides/queues/redeliveries.rb +0 -79
  91. data/lib/bunny/compatibility.rb +0 -24
  92. data/lib/bunny/concurrent/linked_continuation_queue.rb +0 -61
  93. data/lib/bunny/jruby/socket.rb +0 -40
  94. data/lib/bunny/jruby/ssl_socket.rb +0 -53
  95. data/lib/bunny/system_timer.rb +0 -20
  96. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  97. data/repl +0 -3
  98. data/spec/compatibility/queue_declare_spec.rb +0 -44
  99. data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
  100. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -71
  101. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -76
  102. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -225
  103. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  104. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -48
  105. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -79
  106. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -89
  107. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -29
  108. data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
  109. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -74
  110. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  111. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
  112. data/spec/higher_level_api/integration/channel_flow_spec.rb +0 -21
  113. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  114. data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
  115. data/spec/higher_level_api/integration/connection_spec.rb +0 -400
  116. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
  117. data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
  118. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  119. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -52
  120. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  121. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -204
  122. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  123. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  124. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  125. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -31
  126. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  127. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  128. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  129. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -77
  130. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -65
  131. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  132. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -190
  133. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  134. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  135. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  136. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  137. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  138. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -127
  139. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  140. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  141. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  142. data/spec/issues/issue100_spec.rb +0 -42
  143. data/spec/issues/issue141_spec.rb +0 -44
  144. data/spec/issues/issue78_spec.rb +0 -75
  145. data/spec/issues/issue83_spec.rb +0 -31
  146. data/spec/issues/issue97_attachment.json +0 -1
  147. data/spec/issues/issue97_spec.rb +0 -176
  148. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -69
  149. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -100
  150. data/spec/spec_helper.rb +0 -64
  151. data/spec/stress/channel_open_stress_spec.rb +0 -51
  152. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  153. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -69
  154. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -57
  155. data/spec/stress/connection_open_close_spec.rb +0 -40
  156. data/spec/stress/long_running_consumer_spec.rb +0 -83
  157. data/spec/tls/cacert.pem +0 -18
  158. data/spec/tls/client_cert.pem +0 -18
  159. data/spec/tls/client_key.pem +0 -27
  160. data/spec/tls/server_cert.pem +0 -18
  161. data/spec/tls/server_key.pem +0 -27
  162. data/spec/unit/bunny_spec.rb +0 -15
  163. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  164. data/spec/unit/concurrent/condition_spec.rb +0 -82
  165. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  166. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  167. data/spec/unit/system_timer_spec.rb +0 -10
  168. data/spec/unit/version_delivery_tag_spec.rb +0 -28
data/ChangeLog.md DELETED
@@ -1,1092 +0,0 @@
1
- ## Changes between Bunny 1.0.6 and 1.0.7
2
-
3
- ### amq-protocol Update
4
-
5
- Minimum `amq-protocol` version is now `1.9.2` which includes
6
- bug fixes around singed 8 and 16 bit integer decoding.
7
-
8
-
9
-
10
- ## Changes between Bunny 1.0.5 and 1.0.6
11
-
12
- ### Better Exception Handling in Consumers
13
-
14
- Consumer work pools will now correctly catch all exceptions
15
- when dispatching submitted operations, not just `Bunny::Exception`
16
- subclasses.
17
-
18
- ### TLS Without Peer Verification
19
-
20
- Bunny now successfully performs TLS upgrade when peer verification
21
- is disabled.
22
-
23
- Contribute by Jordan Curzon.
24
-
25
- ### Bunny::Session#with_channel Ensures the Channel is Closed
26
-
27
- `Bunny::Session#with_channel` now makes sure the channel is closed
28
- even if provided block raises an exception
29
-
30
- Contributed by Carl Hoerberg.
31
-
32
-
33
- ### Channel Number = 0 is Rejected
34
-
35
- `Bunny::Session#create_channel` will now reject channel number 0.
36
-
37
-
38
-
39
- ## Changes between Bunny 1.0.4 and 1.0.5
40
-
41
- ### Single Threaded Mode Fixes
42
-
43
- Single threaded mode no longer fails with
44
-
45
- ```
46
- undefined method `event_loop'
47
- ```
48
-
49
- ### connection.tune.channel_max No Longer Overflows
50
-
51
- `connection.tune.channel_max` could previously be configured to values
52
- greater than 2^16 - 1 (65535). This would result in a silent overflow
53
- during serialization. The issue was harmless in practice but is still
54
- a bug that can be quite confusing.
55
-
56
- Bunny now caps max number of channels to 65535. This allows it to be
57
- forward compatible with future RabbitMQ versions that may allow limiting
58
- total # of open channels via server configuration.
59
-
60
- ### Thread Leaks Fixes
61
-
62
- Bunny will now correctly release heartbeat sender when allocating
63
- a new one (usually happens only when connection recovers from a network
64
- failure).
65
-
66
- ### amq-protocol Update
67
-
68
- Minimum `amq-protocol` version is now `1.9.0` which includes
69
- bug fixes and performance improvements for channel ID allocator.
70
-
71
-
72
-
73
- ## Changes between Bunny 1.0.3 and 1.0.4
74
-
75
- ### Versioned Delivery Tag Fix
76
-
77
- Versioned delivery tag now ensures all the arguments it operates
78
- (original delivery tag, atomic fixnum instances, etc) are coerced to `Integer`
79
- before comparison.
80
-
81
- GitHub issues: #171.
82
-
83
- ## Changes between Bunny 1.0.2 and 1.0.3
84
-
85
- ### Eliminated Errouneous Debug Statement
86
-
87
- `1.0.3` eliminates a debug log message that should have
88
- never made it into a commit.
89
-
90
-
91
- ## Changes between Bunny 1.0.1 and 1.0.2
92
-
93
- ### Fixes CPU Burn on JRuby
94
-
95
- A silly mistake in `1.0.1` testing process ended up reverting
96
- the fix for #165 and #166. This release corrects it.
97
-
98
-
99
- ## Changes between Bunny 1.0.0 and 1.0.1
100
-
101
- ### Default CA's Paths Are Disabled on JRuby
102
-
103
- Bunny uses OpenSSL provided CA certificate paths. This
104
- caused problems on some platforms on JRuby (see [jruby/jruby#155](https://github.com/jruby/jruby/issues/1055)).
105
-
106
- To avoid these issues, Bunny no longer uses default CA certificate paths on JRuby
107
- (there are no changes for other Rubies), so it's necessary to provide
108
- CA certificate explicitly.
109
-
110
- ### Fixes CPU Burn on JRuby
111
-
112
- Bunny now uses slightly different ways of continuously reading from the socket
113
- on CRuby and JRuby, to prevent abnormally high CPU usage on JRuby after a
114
- certain period of time (the frequency of `EWOULDBLOCK` being raised spiked
115
- sharply).
116
-
117
-
118
- ## Changes between Bunny 1.0.0.rc2 and 1.0.0.rc3
119
-
120
- ### [Authentication Failure Notification](http://www.rabbitmq.com/auth-notification.html) Support
121
-
122
- `Bunny::AuthenticationFailureError` is a new auth failure exception
123
- that subclasses `Bunny::PossibleAuthenticationFailureError` for
124
- backwards compatibility.
125
-
126
- As such, `Bunny::PossibleAuthenticationFailureError`'s error message
127
- has changed.
128
-
129
- This extension is available in RabbitMQ 3.2+.
130
-
131
-
132
- ### Bunny::Session#exchange_exists?
133
-
134
- `Bunny::Session#exchange_exists?` is a new predicate that makes it
135
- easier to check if a exchange exists.
136
-
137
- It uses a one-off channel and `exchange.declare` with `passive` set to true
138
- under the hood.
139
-
140
- ### Bunny::Session#queue_exists?
141
-
142
- `Bunny::Session#queue_exists?` is a new predicate that makes it
143
- easier to check if a queue exists.
144
-
145
- It uses a one-off channel and `queue.declare` with `passive` set to true
146
- under the hood.
147
-
148
-
149
- ### Inline TLS Certificates and Keys
150
-
151
- It is now possible to provide inline client
152
- certificate and private key (as strings) instead
153
- of filesystem paths. The options are the same:
154
-
155
- * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
156
- * `:tls_cert` which now can be a client certificate (public key) in PEM format
157
- * `:tls_key` which now can be a client key (private key) in PEM format
158
- * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
159
-
160
- For example:
161
-
162
- ``` ruby
163
- conn = Bunny.new(:tls => true,
164
- :tls_cert => ENV["TLS_CERTIFICATE"],
165
- :tls_key => ENV["TLS_PRIVATE_KEY"],
166
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
167
- ```
168
-
169
-
170
-
171
- ## Changes between Bunny 1.0.0.rc1 and 1.0.0.rc2
172
-
173
- ### Ruby 1.8.7 Compatibility Fixes
174
-
175
- Ruby 1.8.7 compatibility fixes around timeouts.
176
-
177
-
178
-
179
- ## Changes between Bunny 1.0.0.pre6 and 1.0.0.rc1
180
-
181
- ### amq-protocol Update
182
-
183
- Minimum `amq-protocol` version is now `1.8.0` which includes
184
- a bug fix for messages exactly 128 Kb in size.
185
-
186
-
187
- ### Add timeout Bunny::ConsumerWorkPool#join
188
-
189
- `Bunny::ConsumerWorkPool#join` now accepts an optional
190
- timeout argument.
191
-
192
-
193
- ## Changes between Bunny 1.0.0.pre5 and 1.0.0.pre6
194
-
195
- ### Respect RABBITMQ_URL value
196
-
197
- `RABBITMQ_URL` env variable will now have effect even if
198
- Bunny.new is invoked without arguments.
199
-
200
-
201
-
202
- ## Changes between Bunny 1.0.0.pre4 and 1.0.0.pre5
203
-
204
- ### Ruby 1.8 Compatibility
205
-
206
- Bunny is Ruby 1.8-compatible again and no longer references
207
- `RUBY_ENGINE`.
208
-
209
- ### Bunny::Session.parse_uri
210
-
211
- `Bunny::Session.parse_uri` is a new method that parses
212
- connection URIs into hashes that `Bunny::Session#initialize`
213
- accepts.
214
-
215
- ``` ruby
216
- Bunny::Session.parse_uri("amqp://user:pwd@broker.eng.megacorp.local/myapp_qa")
217
- ```
218
-
219
- ### Default Paths for TLS/SSL CA's on All OS'es
220
-
221
- Bunny now uses OpenSSL to detect default TLS/SSL CA's paths, extending
222
- this feature to OS'es other than Linux.
223
-
224
- Contributed by Jingwen Owen Ou.
225
-
226
-
227
- ## Changes between Bunny 1.0.0.pre3 and 1.0.0.pre4
228
-
229
- ### Default Paths for TLS/SSL CA's on Linux
230
-
231
- Bunny now will use the following TLS/SSL CA's paths on Linux by default:
232
-
233
- * `/etc/ssl/certs/ca-certificates.crt` on Ubuntu/Debian
234
- * `/etc/ssl/certs/ca-bundle.crt` on Amazon Linux
235
- * `/etc/ssl/ca-bundle.pem` on OpenSUSE
236
- * `/etc/pki/tls/certs/ca-bundle.crt` on Fedora/RHEL
237
-
238
- and will log a warning if no CA files are available via default paths
239
- or `:tls_ca_certificates`.
240
-
241
- Contributed by Carl Hörberg.
242
-
243
- ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
244
-
245
- It is now possible to re-register a consumer (and use any other synchronous methods)
246
- from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
247
- thread pool.
248
-
249
-
250
- ### Bunny::Session#close Fixed for Single Threaded Connections
251
-
252
- `Bunny::Session#close` with single threaded connections no longer fails
253
- with a nil pointer exception.
254
-
255
-
256
-
257
- ## Changes between Bunny 1.0.0.pre2 and 1.0.0.pre3
258
-
259
- This release has **breaking API changes**.
260
-
261
- ### Safe[r] basic.ack, basic.nack and basic.reject implementation
262
-
263
- Previously if a channel was recovered (reopened) by automatic connection
264
- recovery before a message was acknowledged or rejected, it would cause
265
- any operation on the channel that uses delivery tags to fail and
266
- cause the channel to be closed.
267
-
268
- To avoid this issue, every channel keeps a counter of how many times
269
- it has been reopened and marks delivery tags with them. Using a stale
270
- tag to ack or reject a message will produce no method sent to RabbitMQ.
271
- Note that unacknowledged messages will be requeued by RabbitMQ when connection
272
- goes down anyway.
273
-
274
- This involves an API change: `Bunny::DeliveryMetadata#delivery_tag` is now
275
- and instance of a class that responds to `#tag` and `#to_i` and is accepted
276
- by `Bunny::Channel#ack` and related methods.
277
-
278
- Integers are still accepted by the same methods.
279
-
280
-
281
- ## Changes between Bunny 1.0.0.pre1 and 1.0.0.pre2
282
-
283
- ### Exclusivity Violation for Consumers Now Raises a Reasonable Exception
284
-
285
- When a second consumer is registered for the same queue on different channels,
286
- a reasonable exception (`Bunny::AccessRefused`) will be raised.
287
-
288
-
289
- ### Reentrant Mutex Implementation
290
-
291
- Bunny now allows mutex impl to be configurable, uses reentrant Monitor
292
- by default.
293
-
294
- Non-reentrant mutexes is a major PITA and may affect code that
295
- uses Bunny.
296
-
297
- Avg. publishing throughput with Monitor drops slightly from
298
- 5.73 Khz to 5.49 Khz (about 4% decrease), which is reasonable
299
- for Bunny.
300
-
301
- Apps that need these 4% can configure what mutex implementation
302
- is used on per-connection basis.
303
-
304
- ### Eliminated Race Condition in Bunny::Session#close
305
-
306
- `Bunny::Session#close` had a race condition that caused (non-deterministic)
307
- exceptions when connection transport was closed before connection
308
- reader loop was guaranteed to have stopped.
309
-
310
- ### connection.close Raises Exceptions on Connection Thread
311
-
312
- Connection-level exceptions (including when a connection is closed via
313
- management UI or `rabbitmqctl`) will now be raised on the connection
314
- thread so they
315
-
316
- * can be handled by applications
317
- * do not start connection recovery, which may be uncalled for
318
-
319
- ### Client TLS Certificates are Optional
320
-
321
- Bunny will no longer require client TLS certificates. Note that CA certificate
322
- list is still necessary.
323
-
324
- If RabbitMQ TLS configuration requires peer verification, client certificate
325
- and private key are mandatory.
326
-
327
-
328
- ## Changes between Bunny 0.9.0 and 1.0.0.pre1
329
-
330
- ### Publishing Over Closed Connections
331
-
332
- Publishing a message over a closed connection (during a network outage, before the connection
333
- is open) will now correctly result in an exception.
334
-
335
- Contributed by Matt Campbell.
336
-
337
-
338
- ### Reliability Improvement in Automatic Network Failure Recovery
339
-
340
- Bunny now ensures a new connection transport (socket) is initialized
341
- before any recovery is attempted.
342
-
343
-
344
- ### Reliability Improvement in Bunny::Session#create_channel
345
-
346
- `Bunny::Session#create_channel` now uses two separate mutexes to avoid
347
- a (very rare) issue when the previous implementation would try to
348
- re-acquire the same mutex and fail (Ruby mutexes are non-reentrant).
349
-
350
-
351
-
352
- ## Changes between Bunny 0.9.0.rc1 and 0.9.0.rc2
353
-
354
- ### Channel Now Properly Restarts Consumer Pool
355
-
356
- In a case when all consumers are cancelled, `Bunny::Channel`
357
- will shut down its consumer delivery thread pool.
358
-
359
- It will also now mark the pool as not running so that it can be
360
- started again successfully if new consumers are registered later.
361
-
362
- GH issue: #133.
363
-
364
-
365
- ### Bunny::Queue#pop_waiting is Removed
366
-
367
- A little bit of background: on MRI, the method raised `ThreadErrors`
368
- reliably. On JRuby, we used a different [internal] queue implementation
369
- from JDK so it wasn't an issue.
370
-
371
- `Timeout.timeout` uses `Thread#kill` and `Thread#join`, both of which
372
- eventually attempt to acquire a mutex used by Queue#pop, which Bunny
373
- currently uses for continuations. The mutex is already has an owner
374
- and so a ThreadError is raised.
375
-
376
- This is not a problem on JRuby because there we don't use Ruby's
377
- Timeout and Queue and instead rely on a JDK concurrency primitive
378
- which provides "poll with a timeout".
379
-
380
- [The issue with `Thread#kill` and `Thread#raise`](http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html)
381
- has been first investigated and blogged about by Ruby implementers
382
- in 2008.
383
-
384
- Finding a workaround will probably take a bit of time and may involve
385
- reimplementing standard library and core classes.
386
-
387
- We don't want this issue to block Bunny 0.9 release. Neither we want
388
- to ship a broken feature. So as a result, we will drop
389
- Bunny::Queue#pop_waiting since it cannot be reliably implemented in a
390
- reasonable amount of time on MRI.
391
-
392
- Per issue #131.
393
-
394
-
395
- ### More Flexible SSLContext Configuration
396
-
397
- Bunny will now upgrade connection to SSL in `Bunny::Session#start`,
398
- so it is possible to fine tune SSLContext and socket settings
399
- before that:
400
-
401
- ``` ruby
402
- require "bunny"
403
-
404
- conn = Bunny.new(:tls => true,
405
- :tls_cert => "examples/tls/client_cert.pem",
406
- :tls_key => "examples/tls/client_key.pem",
407
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
408
-
409
- puts conn.transport.socket.inspect
410
- puts conn.transport.tls_context.inspect
411
- ```
412
-
413
- This also means that `Bunny.new` will now open the socket. Previously
414
- it was only done when `Bunny::Session#start` was invoked.
415
-
416
-
417
- ## Changes between Bunny 0.9.0.pre13 and 0.9.0.rc1
418
-
419
- ### TLS Support
420
-
421
- Bunny 0.9 finally supports TLS. There are 3 new options `Bunny.new` takes:
422
-
423
- * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
424
- * `:tls_cert` which is a string path to the client certificate (public key) in PEM format
425
- * `:tls_key` which is a string path to the client key (private key) in PEM format
426
- * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
427
-
428
- An example:
429
-
430
- ``` ruby
431
- conn = Bunny.new(:tls => true,
432
- :tls_cert => "examples/tls/client_cert.pem",
433
- :tls_key => "examples/tls/client_key.pem",
434
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
435
- ```
436
-
437
-
438
- ### Bunny::Queue#pop_waiting
439
-
440
- **This function was removed in v0.9.0.rc2**
441
-
442
- `Bunny::Queue#pop_waiting` is a new function that mimics `Bunny::Queue#pop`
443
- but will wait until a message is available. It uses a `:timeout` option and will
444
- raise an exception if the timeout is hit:
445
-
446
- ``` ruby
447
- # given 1 message in the queue,
448
- # works exactly as Bunny::Queue#get
449
- q.pop_waiting
450
-
451
- # given no messages in the queue, will wait for up to 0.5 seconds
452
- # for a message to become available. Raises an exception if the timeout
453
- # is hit
454
- q.pop_waiting(:timeout => 0.5)
455
- ```
456
-
457
- This method only makes sense for collecting Request/Reply ("RPC") replies.
458
-
459
-
460
- ### Bunny::InvalidCommand is now Bunny::CommandInvalid
461
-
462
- `Bunny::InvalidCommand` is now `Bunny::CommandInvalid` (follows
463
- the exception class naming convention based on response status
464
- name).
465
-
466
-
467
-
468
- ## Changes between Bunny 0.9.0.pre12 and 0.9.0.pre13
469
-
470
- ### Channels Without Consumers Now Tear Down Consumer Pools
471
-
472
- Channels without consumers left (when all consumers were cancelled)
473
- will now tear down their consumer work thread pools, thus making
474
- `HotBunnies::Queue#subscribe(:block => true)` calls unblock.
475
-
476
- This is typically the desired behavior.
477
-
478
- ### Consumer and Channel Available In Delivery Handlers
479
-
480
- Delivery handlers registered via `Bunny::Queue#subscribe` now will have
481
- access to the consumer and channel they are associated with via the
482
- `delivery_info` argument:
483
-
484
- ``` ruby
485
- q.subscribe do |delivery_info, properties, payload|
486
- delivery_info.consumer # => the consumer this delivery is for
487
- delivery_info.consumer # => the channel this delivery is on
488
- end
489
- ```
490
-
491
- This allows using `Bunny::Queue#subscribe` for one-off consumers
492
- much easier, including when used with the `:block` option.
493
-
494
- ### Bunny::Exchange#wait_for_confirms
495
-
496
- `Bunny::Exchange#wait_for_confirms` is a convenience method on `Bunny::Exchange` that
497
- delegates to the method with the same name on exchange's channel.
498
-
499
-
500
- ## Changes between Bunny 0.9.0.pre11 and 0.9.0.pre12
501
-
502
- ### Ruby 1.8 Compatibility Regression Fix
503
-
504
- `Bunny::Socket` no longer uses Ruby 1.9-specific constants.
505
-
506
-
507
- ### Bunny::Channel#wait_for_confirms Return Value Regression Fix
508
-
509
- `Bunny::Channel#wait_for_confirms` returns `true` or `false` again.
510
-
511
-
512
-
513
- ## Changes between Bunny 0.9.0.pre10 and 0.9.0.pre11
514
-
515
- ### Bunny::Session#create_channel Now Accepts Consumer Work Pool Size
516
-
517
- `Bunny::Session#create_channel` now accepts consumer work pool size as
518
- the second argument:
519
-
520
- ``` ruby
521
- # nil means channel id will be allocated by Bunny.
522
- # 8 is the number of threads in the consumer work pool this channel will use.
523
- ch = conn.create_channel(nil, 8)
524
- ```
525
-
526
- ### Heartbeat Fix For Long Running Consumers
527
-
528
- Long running consumers that don't send any data will no longer
529
- suffer from connections closed by RabbitMQ because of skipped
530
- heartbeats.
531
-
532
- Activity tracking now takes sent frames into account.
533
-
534
-
535
- ### Time-bound continuations
536
-
537
- If a network loop exception causes "main" session thread to never
538
- receive a response, methods such as `Bunny::Channel#queue` will simply time out
539
- and raise Timeout::Error now, which can be handled.
540
-
541
- It will not start automatic recovery for two reasons:
542
-
543
- * It will be started in the network activity loop anyway
544
- * It may do more damage than good
545
-
546
- Kicking off network recovery manually is a matter of calling
547
- `Bunny::Session#handle_network_failure`.
548
-
549
- The main benefit of this implementation is that it will never
550
- block the main app/session thread forever, and it is really
551
- efficient on JRuby thanks to a j.u.c. blocking queue.
552
-
553
- Fixes #112.
554
-
555
-
556
- ### Logging Support
557
-
558
- Every Bunny connection now has a logger. By default, Bunny will use STDOUT
559
- as logging device. This is configurable using the `:log_file` option:
560
-
561
- ``` ruby
562
- require "bunny"
563
-
564
- conn = Bunny.new(:log_level => :warn)
565
- ```
566
-
567
- or the `BUNNY_LOG_LEVEL` environment variable that can take one of the following
568
- values:
569
-
570
- * `debug` (very verbose)
571
- * `info`
572
- * `warn`
573
- * `error`
574
- * `fatal` (least verbose)
575
-
576
- Severity is set to `warn` by default. To disable logging completely, set the level
577
- to `fatal`.
578
-
579
- To redirect logging to a file or any other object that can act as an I/O entity,
580
- pass it to the `:log_file` option.
581
-
582
-
583
- ## Changes between Bunny 0.9.0.pre9 and 0.9.0.pre10
584
-
585
- This release contains a **breaking API change**.
586
-
587
- ### Concurrency Improvements On JRuby
588
-
589
- On JRuby, Bunny now will use `java.util.concurrent`-backed implementations
590
- of some of the concurrency primitives. This both improves client stability
591
- (JDK concurrency primitives has been around for 9 years and have
592
- well-defined, documented semantics) and opens the door to solving
593
- some tricky failure handling problems in the future.
594
-
595
-
596
- ### Explicitly Closed Sockets
597
-
598
- Bunny now will correctly close the socket previous connection had
599
- when recovering from network issues.
600
-
601
-
602
- ### Bunny::Exception Now Extends StandardError
603
-
604
- `Bunny::Exception` now inherits from `StandardError` and not `Exception`.
605
-
606
- Naked rescue like this
607
-
608
- ``` ruby
609
- begin
610
- # ...
611
- rescue => e
612
- # ...
613
- end
614
- ```
615
-
616
- catches only descendents of `StandardError`. Most people don't
617
- know this and this is a very counter-intuitive practice, but
618
- apparently there is code out there that can't be changed that
619
- depends on this behavior.
620
-
621
- This is a **breaking API change**.
622
-
623
-
624
-
625
- ## Changes between Bunny 0.9.0.pre8 and 0.9.0.pre9
626
-
627
- ### Bunny::Session#start Now Returns a Session
628
-
629
- `Bunny::Session#start` now returns a session instead of the default channel
630
- (which wasn't intentional, default channel is a backwards-compatibility implementation
631
- detail).
632
-
633
- `Bunny::Session#start` also no longer leaves dead threads behind if called multiple
634
- times on the same connection.
635
-
636
-
637
- ### More Reliable Heartbeat Sender
638
-
639
- Heartbeat sender no longer slips into an infinite loop if it encounters an exception.
640
- Instead, it will just stop (and presumably re-started when the network error recovery
641
- kicks in or the app reconnects manually).
642
-
643
-
644
- ### Network Recovery After Delay
645
-
646
- Network reconnection now kicks in after a delay to avoid aggressive
647
- reconnections in situations when we don't want to endlessly reconnect
648
- (e.g. when the connection was closed via the Management UI).
649
-
650
- The `:network_recovery_interval` option passed to `Bunny::Session#initialize` and `Bunny.new`
651
- controls the interval. Default is 5 seconds.
652
-
653
-
654
- ### Default Heartbeat Value Is Now Server-Defined
655
-
656
- Bunny will now use heartbeat value provided by RabbitMQ by default.
657
-
658
-
659
-
660
- ## Changes between Bunny 0.9.0.pre7 and 0.9.0.pre8
661
-
662
- ### Stability Improvements
663
-
664
- Several stability improvements in the network
665
- layer, connection error handling, and concurrency hazards.
666
-
667
-
668
- ### Automatic Connection Recovery Can Be Disabled
669
-
670
- Automatic connection recovery now can be disabled by passing
671
- the `:automatically_recover => false` option to `Bunny#initialize`).
672
-
673
- When the recovery is disabled, network I/O-related exceptions will
674
- cause an exception to be raised in thee thread the connection was
675
- started on.
676
-
677
-
678
- ### No Timeout Control For Publishing
679
-
680
- `Bunny::Exchange#publish` and `Bunny::Channel#basic_publish` no
681
- longer perform timeout control (using the timeout module) which
682
- roughly increases throughput for flood publishing by 350%.
683
-
684
- Apps that need delivery guarantees should use publisher confirms.
685
-
686
-
687
-
688
- ## Changes between Bunny 0.9.0.pre6 and 0.9.0.pre7
689
-
690
- ### Bunny::Channel#on_error
691
-
692
- `Bunny::Channel#on_error` is a new method that lets you define
693
- handlers for channel errors that are caused by methods that have no
694
- responses in the protocol (`basic.ack`, `basic.reject`, and `basic.nack`).
695
-
696
- This is rarely necessary but helps make sure no error goes unnoticed.
697
-
698
- Example:
699
-
700
- ``` ruby
701
- channel.on_error |ch, channel_close|
702
- puts channel_close.inspect
703
- end
704
- ```
705
-
706
- ### Fixed Framing of Larger Messages With Unicode Characters
707
-
708
- Larger (over 128K) messages with non-ASCII characters are now always encoded
709
- correctly with amq-protocol `1.2.0`.
710
-
711
-
712
- ### Efficiency Improvements
713
-
714
- Publishing of large messages is now done more efficiently.
715
-
716
- Contributed by Greg Brockman.
717
-
718
-
719
- ### API Reference
720
-
721
- [Bunny API reference](http://reference.rubybunny.info) is now up online.
722
-
723
-
724
- ### Bunny::Channel#basic_publish Support For :persistent
725
-
726
- `Bunny::Channel#basic_publish` now supports both
727
- `:delivery_mode` and `:persistent` options.
728
-
729
- ### Bunny::Channel#nacked_set
730
-
731
- `Bunny::Channel#nacked_set` is a counter-part to `Bunny::Channel#unacked_set`
732
- that contains `basic.nack`-ed (rejected) delivery tags.
733
-
734
-
735
- ### Single-threaded Network Activity Mode
736
-
737
- Passing `:threaded => false` to `Bunny.new` now will use the same
738
- thread for publisher confirmations (may be useful for retry logic
739
- implementation).
740
-
741
- Contributed by Greg Brockman.
742
-
743
-
744
- ## Changes between Bunny 0.9.0.pre5 and 0.9.0.pre6
745
-
746
- ### Automatic Network Failure Recovery
747
-
748
- Automatic Network Failure Recovery is a new Bunny feature that was earlier
749
- impemented and vetted out in [amqp gem](http://rubyamqp.info). What it does
750
- is, when a network activity loop detects an issue, it will try to
751
- periodically recover [first TCP, then] AMQP 0.9.1 connection, reopen
752
- all channels, recover all exchanges, queues, bindings and consumers
753
- on those channels (to be clear: this only includes entities and consumers added via
754
- Bunny).
755
-
756
- Publishers and consumers will continue operating shortly after the network
757
- connection recovers.
758
-
759
- Learn more in the [Error Handling and Recovery](http://rubybunny.info/articles/error_handling.html)
760
- documentation guide.
761
-
762
- ### Confirms Listeners
763
-
764
- Bunny now supports listeners (callbacks) on
765
-
766
- ``` ruby
767
- ch.confirm_select do |delivery_tag, multiple, nack|
768
- # handle confirms (e.g. perform retries) here
769
- end
770
- ```
771
-
772
- Contributed by Greg Brockman.
773
-
774
- ### Publisher Confirms Improvements
775
-
776
- Publisher confirms implementation now uses non-strict equality (`<=`) for
777
- cases when multiple messages are confirmed by RabbitMQ at once.
778
-
779
- `Bunny::Channel#unconfirmed_set` is now part of the public API that lets
780
- developers access unconfirmed delivery tags to perform retries and such.
781
-
782
- Contributed by Greg Brockman.
783
-
784
- ### Publisher Confirms Concurrency Fix
785
-
786
- `Bunny::Channel#wait_for_confirms` will now correctly block the calling
787
- thread until all pending confirms are received.
788
-
789
-
790
- ## Changes between Bunny 0.9.0.pre4 and 0.9.0.pre5
791
-
792
- ### Channel Errors Reset
793
-
794
- Channel error information is now properly reset when a channel is (re)opened.
795
-
796
- GH issue: #83.
797
-
798
- ### Bunny::Consumer#initial Default Change
799
-
800
- the default value of `Bunny::Consumer` noack argument changed from false to true
801
- for consistency.
802
-
803
- ### Bunny::Session#prefetch Removed
804
-
805
- Global prefetch is not implemented in RabbitMQ, so `Bunny::Session#prefetch`
806
- is gone from the API.
807
-
808
- ### Queue Redeclaration Bug Fix
809
-
810
- Fixed a problem when a queue was not declared after being deleted and redeclared
811
-
812
- GH issue: #80
813
-
814
- ### Channel Cache Invalidation
815
-
816
- Channel queue and exchange caches are now properly invalidated when queues and
817
- exchanges are deleted.
818
-
819
-
820
- ## Changes between Bunny 0.9.0.pre3 and 0.9.0.pre4
821
-
822
- ### Heartbeats Support Fixes
823
-
824
- Heartbeats are now correctly sent at safe intervals (half of the configured
825
- interval). In addition, setting `:heartbeat => 0` (or `nil`) will disable
826
- heartbeats, just like in Bunny 0.8 and [amqp gem](http://rubyamqp.info).
827
-
828
- Default `:heartbeat` value is now `600` (seconds), the same as RabbitMQ 3.0
829
- default.
830
-
831
-
832
- ### Eliminate Race Conditions When Registering Consumers
833
-
834
- Fixes a potential race condition between `basic.consume-ok` handler and
835
- delivery handler when a consumer is registered for a queue that has
836
- messages in it.
837
-
838
- GH issue: #78.
839
-
840
- ### Support for Alternative Authentication Mechanisms
841
-
842
- Bunny now supports two authentication mechanisms and can be extended
843
- to support more. The supported methods are `"PLAIN"` (username
844
- and password) and `"EXTERNAL"` (typically uses TLS, UNIX sockets or
845
- another mechanism that does not rely on username/challenge pairs).
846
-
847
- To use the `"EXTERNAL"` method, pass `:auth_mechanism => "EXTERNAL"` to
848
- `Bunny.new`:
849
-
850
- ``` ruby
851
- # uses the EXTERNAL authentication mechanism
852
- conn = Bunny.new(:auth_method => "EXTERNAL")
853
- conn.start
854
- ```
855
-
856
- ### Bunny::Consumer#cancel
857
-
858
- A new high-level API method: `Bunny::Consumer#cancel`, can be used to
859
- cancel a consumer. `Bunny::Queue#subscribe` will now return consumer
860
- instances when the `:block` option is passed in as `false`.
861
-
862
-
863
- ### Bunny::Exchange#delete Behavior Change
864
-
865
- `Bunny::Exchange#delete` will no longer delete pre-declared exchanges
866
- that cannot be declared by Bunny (`amq.*` and the default exchange).
867
-
868
-
869
- ### Bunny::DeliveryInfo#redelivered?
870
-
871
- `Bunny::DeliveryInfo#redelivered?` is a new method that is an alias
872
- to `Bunny::DeliveryInfo#redelivered` but follows the Ruby community convention
873
- about predicate method names.
874
-
875
- ### Corrected Bunny::DeliveryInfo#delivery_tag Name
876
-
877
- `Bunny::DeliveryInfo#delivery_tag` had a typo which is now fixed.
878
-
879
-
880
- ## Changes between Bunny 0.9.0.pre2 and 0.9.0.pre3
881
-
882
- ### Client Capabilities
883
-
884
- Bunny now correctly lists RabbitMQ extensions it currently supports in client capabilities:
885
-
886
- * `basic.nack`
887
- * exchange-to-exchange bindings
888
- * consumer cancellation notifications
889
- * publisher confirms
890
-
891
- ### Publisher Confirms Support
892
-
893
- [Lightweight Publisher Confirms](http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/) is a
894
- RabbitMQ feature that lets publishers keep track of message routing without adding
895
- noticeable throughput degradation as it is the case with AMQP 0.9.1 transactions.
896
-
897
- Bunny `0.9.0.pre3` supports publisher confirms. Publisher confirms are enabled per channel,
898
- using the `Bunny::Channel#confirm_select` method. `Bunny::Channel#wait_for_confirms` is a method
899
- that blocks current thread until the client gets confirmations for all unconfirmed published
900
- messages:
901
-
902
- ``` ruby
903
- ch = connection.create_channel
904
- ch.confirm_select
905
-
906
- ch.using_publisher_confirmations? # => true
907
-
908
- q = ch.queue("", :exclusive => true)
909
- x = ch.default_exchange
910
-
911
- 5000.times do
912
- x.publish("xyzzy", :routing_key => q.name)
913
- end
914
-
915
- ch.next_publish_seq_no.should == 5001
916
- ch.wait_for_confirms # waits until all 5000 published messages are acknowledged by RabbitMQ
917
- ```
918
-
919
-
920
- ### Consumers as Objects
921
-
922
- It is now possible to register a consumer as an object instead
923
- of a block. Consumers that are class instances support cancellation
924
- notifications (e.g. when a queue they're registered with is deleted).
925
-
926
- To support this, Bunny introduces two new methods: `Bunny::Channel#basic_consume_with`
927
- and `Bunny::Queue#subscribe_with`, that operate on consumer objects. Objects are
928
- supposed to respond to three selectors:
929
-
930
- * `:handle_delivery` with 3 arguments
931
- * `:handle_cancellation` with 1 argument
932
- * `:consumer_tag=` with 1 argument
933
-
934
- An example:
935
-
936
- ``` ruby
937
- class ExampleConsumer < Bunny::Consumer
938
- def cancelled?
939
- @cancelled
940
- end
941
-
942
- def handle_cancellation(_)
943
- @cancelled = true
944
- end
945
- end
946
-
947
- # "high-level" API
948
- ch1 = connection.create_channel
949
- q1 = ch1.queue("", :auto_delete => true)
950
-
951
- consumer = ExampleConsumer.new(ch1, q)
952
- q1.subscribe_with(consumer)
953
-
954
- # "low-level" API
955
- ch2 = connection.create_channel
956
- q1 = ch2.queue("", :auto_delete => true)
957
-
958
- consumer = ExampleConsumer.new(ch2, q)
959
- ch2.basic_consume_with.(consumer)
960
- ```
961
-
962
- ### RABBITMQ_URL ENV variable support
963
-
964
- If `RABBITMQ_URL` environment variable is set, Bunny will assume
965
- it contains a valid amqp URI string and will use it. This is convenient
966
- with some PaaS technologies such as Heroku.
967
-
968
-
969
- ## Changes between Bunny 0.9.0.pre1 and 0.9.0.pre2
970
-
971
- ### Change Bunny::Queue#pop default for :ack to false
972
-
973
- It makes more sense for beginners that way.
974
-
975
-
976
- ### Bunny::Queue#subscribe now support the new :block option
977
-
978
- `Bunny::Queue#subscribe` support the new `:block` option
979
- (a boolean).
980
-
981
- It controls whether the current thread will be blocked
982
- by `Bunny::Queue#subscribe`.
983
-
984
-
985
- ### Bunny::Exchange#publish now supports :key again
986
-
987
- `Bunny::Exchange#publish` now supports `:key` as an alias for
988
- `:routing_key`.
989
-
990
-
991
- ### Bunny::Session#queue et al.
992
-
993
- `Bunny::Session#queue`, `Bunny::Session#direct`, `Bunny::Session#fanout`, `Bunny::Session#topic`,
994
- and `Bunny::Session#headers` were added to simplify migration. They all delegate to their respective
995
- `Bunny::Channel` methods on the default channel every connection has.
996
-
997
-
998
- ### Bunny::Channel#exchange, Bunny::Session#exchange
999
-
1000
- `Bunny::Channel#exchange` and `Bunny::Session#exchange` were added to simplify
1001
- migration:
1002
-
1003
- ``` ruby
1004
- b = Bunny.new
1005
- b.start
1006
-
1007
- # uses default connection channel
1008
- x = b.exchange("logs.events", :topic)
1009
- ```
1010
-
1011
- ### Bunny::Queue#subscribe now properly takes 3 arguments
1012
-
1013
- ``` ruby
1014
- q.subscribe(:exclusive => false, :ack => false) do |delivery_info, properties, payload|
1015
- # ...
1016
- end
1017
- ```
1018
-
1019
-
1020
-
1021
- ## Changes between Bunny 0.8.x and 0.9.0.pre1
1022
-
1023
- ### New convenience functions: Bunny::Channel#fanout, Bunny::Channel#topic
1024
-
1025
- `Bunny::Channel#fanout`, `Bunny::Channel#topic`, `Bunny::Channel#direct`, `Bunny::Channel#headers`,
1026
- and`Bunny::Channel#default_exchange` are new convenience methods to instantiate exchanges:
1027
-
1028
- ``` ruby
1029
- conn = Bunny.new
1030
- conn.start
1031
-
1032
- ch = conn.create_channel
1033
- x = ch.fanout("logging.events", :durable => true)
1034
- ```
1035
-
1036
-
1037
- ### Bunny::Queue#pop and consumer handlers (Bunny::Queue#subscribe) signatures have changed
1038
-
1039
- Bunny `< 0.9.x` example:
1040
-
1041
- ``` ruby
1042
- h = queue.pop
1043
-
1044
- puts h[:delivery_info], h[:header], h[:payload]
1045
- ```
1046
-
1047
- Bunny `>= 0.9.x` example:
1048
-
1049
- ``` ruby
1050
- delivery_info, properties, payload = queue.pop
1051
- ```
1052
-
1053
- The improve is both in that Ruby has positional destructuring, e.g.
1054
-
1055
- ``` ruby
1056
- delivery_info, _, content = q.pop
1057
- ```
1058
-
1059
- but not hash destructuring, like, say, Clojure does.
1060
-
1061
- In addition we return nil for content when it should be nil
1062
- (basic.get-empty) and unify these arguments betwee
1063
-
1064
- * Bunny::Queue#pop
1065
-
1066
- * Consumer (Bunny::Queue#subscribe, etc) handlers
1067
-
1068
- * Returned message handlers
1069
-
1070
- The unification moment was the driving factor.
1071
-
1072
-
1073
-
1074
- ### Bunny::Client#write now raises Bunny::ConnectionError
1075
-
1076
- Bunny::Client#write now raises `Bunny::ConnectionError` instead of `Bunny::ServerDownError` when network
1077
- I/O operations fail.
1078
-
1079
-
1080
- ### Bunny::Client.create_channel now uses a bitset-based allocator
1081
-
1082
- Instead of reusing channel instances, `Bunny::Client.create_channel` now opens new channels and
1083
- uses bitset-based allocator to keep track of used channel ids. This avoids situations when
1084
- channels are reused or shared without developer's explicit intent but also work well for
1085
- long running applications that aggressively open and release channels.
1086
-
1087
- This is also how amqp gem and RabbitMQ Java client manage channel ids.
1088
-
1089
-
1090
- ### Bunny::ServerDownError is now Bunny::TCPConnectionFailed
1091
-
1092
- `Bunny::ServerDownError` is now an alias for `Bunny::TCPConnectionFailed`