bunny 2.7.4 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +61 -35
  3. data/lib/bunny/channel.rb +186 -50
  4. data/lib/bunny/channel_id_allocator.rb +3 -1
  5. data/lib/bunny/consumer.rb +2 -2
  6. data/lib/bunny/consumer_work_pool.rb +2 -1
  7. data/lib/bunny/cruby/socket.rb +3 -0
  8. data/lib/bunny/cruby/ssl_socket.rb +6 -1
  9. data/lib/bunny/delivery_info.rb +1 -1
  10. data/lib/bunny/heartbeat_sender.rb +2 -1
  11. data/lib/bunny/jruby/ssl_socket.rb +5 -0
  12. data/lib/bunny/queue.rb +36 -8
  13. data/lib/bunny/reader_loop.rb +22 -10
  14. data/lib/bunny/session.rb +152 -65
  15. data/lib/bunny/test_kit.rb +14 -0
  16. data/lib/bunny/transport.rb +132 -49
  17. data/lib/bunny/version.rb +1 -1
  18. data/lib/bunny.rb +45 -4
  19. metadata +37 -225
  20. data/.github/ISSUE_TEMPLATE.md +0 -18
  21. data/.gitignore +0 -28
  22. data/.rspec +0 -1
  23. data/.travis.yml +0 -20
  24. data/.yardopts +0 -8
  25. data/CONTRIBUTING.md +0 -111
  26. data/ChangeLog.md +0 -1831
  27. data/Gemfile +0 -53
  28. data/LICENSE +0 -21
  29. data/Rakefile +0 -46
  30. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  31. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  32. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  33. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  34. data/benchmarks/channel_open.rb +0 -28
  35. data/benchmarks/mutex_and_monitor.rb +0 -42
  36. data/benchmarks/queue_declare.rb +0 -29
  37. data/benchmarks/queue_declare_and_bind.rb +0 -29
  38. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  39. data/benchmarks/synchronized_sorted_set.rb +0 -53
  40. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  41. data/bin/ci/before_build +0 -46
  42. data/bunny.gemspec +0 -35
  43. data/docker/Dockerfile +0 -16
  44. data/docker/docker-entrypoint.sh +0 -37
  45. data/docker-compose.yml +0 -18
  46. data/examples/connection/authentication_failure.rb +0 -16
  47. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  48. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  49. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  50. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  51. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  52. data/examples/connection/channel_level_exception.rb +0 -27
  53. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  54. data/examples/connection/heartbeat.rb +0 -17
  55. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  56. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  57. data/examples/connection/unknown_host.rb +0 -16
  58. data/examples/consumers/high_and_low_priority.rb +0 -50
  59. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  60. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  61. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  62. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  63. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  64. data/examples/guides/extensions/basic_nack.rb +0 -33
  65. data/examples/guides/extensions/connection_blocked.rb +0 -35
  66. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  67. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  68. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  69. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  70. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  71. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  72. data/examples/guides/extensions/queue_lease.rb +0 -26
  73. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  74. data/examples/guides/getting_started/blabbr.rb +0 -27
  75. data/examples/guides/getting_started/hello_world.rb +0 -22
  76. data/examples/guides/getting_started/weathr.rb +0 -49
  77. data/examples/guides/queues/one_off_consumer.rb +0 -25
  78. data/examples/guides/queues/redeliveries.rb +0 -81
  79. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  80. data/repl +0 -3
  81. data/spec/config/enabled_plugins +0 -1
  82. data/spec/config/rabbitmq.config +0 -19
  83. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  84. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  85. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -349
  86. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  87. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  88. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  89. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  90. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  91. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  92. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  93. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
  94. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  95. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -471
  96. data/spec/higher_level_api/integration/connection_spec.rb +0 -559
  97. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  98. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  99. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  100. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  101. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  102. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  103. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  104. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  105. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  106. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  107. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  108. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  109. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  110. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  111. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  112. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -221
  113. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  114. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  115. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  116. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  117. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  118. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -222
  119. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  120. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  121. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  122. data/spec/issues/issue100_spec.rb +0 -42
  123. data/spec/issues/issue141_spec.rb +0 -43
  124. data/spec/issues/issue202_spec.rb +0 -15
  125. data/spec/issues/issue224_spec.rb +0 -40
  126. data/spec/issues/issue465_spec.rb +0 -32
  127. data/spec/issues/issue78_spec.rb +0 -72
  128. data/spec/issues/issue83_spec.rb +0 -30
  129. data/spec/issues/issue97_attachment.json +0 -1
  130. data/spec/issues/issue97_spec.rb +0 -175
  131. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  132. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  133. data/spec/spec_helper.rb +0 -51
  134. data/spec/stress/channel_close_stress_spec.rb +0 -64
  135. data/spec/stress/channel_open_stress_spec.rb +0 -84
  136. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  137. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  138. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  139. data/spec/stress/connection_open_close_spec.rb +0 -52
  140. data/spec/stress/long_running_consumer_spec.rb +0 -84
  141. data/spec/tls/ca_certificate.pem +0 -29
  142. data/spec/tls/ca_key.pem +0 -52
  143. data/spec/tls/client_certificate.pem +0 -29
  144. data/spec/tls/client_key.pem +0 -51
  145. data/spec/tls/generate-server-cert.sh +0 -8
  146. data/spec/tls/server-openssl.cnf +0 -10
  147. data/spec/tls/server.csr +0 -16
  148. data/spec/tls/server_certificate.pem +0 -29
  149. data/spec/tls/server_key.pem +0 -51
  150. data/spec/unit/bunny_spec.rb +0 -15
  151. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  152. data/spec/unit/concurrent/condition_spec.rb +0 -82
  153. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  154. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  155. data/spec/unit/exchange_recovery_spec.rb +0 -39
  156. data/spec/unit/version_delivery_tag_spec.rb +0 -28
data/ChangeLog.md DELETED
@@ -1,1831 +0,0 @@
1
- ## Changes between Bunny 2.7.4 and 2.7.5 (unreleased)
2
-
3
- No changes yet.
4
-
5
-
6
- ## Changes between Bunny 2.7.3 and 2.7.4 (Jan 9th, 2018)
7
-
8
- ### amq-protocol Dependency
9
-
10
- This version depends on amq-protocol `2.2.x`.
11
-
12
- GitHub issue: [#538](https://github.com/ruby-amqp/bunny/issues/538).
13
-
14
-
15
- ## Changes between Bunny 2.7.2 and 2.7.3 (Dec 19th, 2017)
16
-
17
- ### JRuby 9K Compatibility
18
-
19
- A JRuby 9K compatibility issue was corrected by Marian Posăceanu.
20
- Note that JRuby users are recommended to use [March Hare](http://rubymarchhare.info/), a JRuby-oriented client, instead
21
- of Bunny.
22
-
23
- GitHub issue: [#529](https://github.com/ruby-amqp/bunny/pull/529)
24
-
25
- ### Connection Exceptions are Logged as Warning with Automatic Recovery
26
-
27
- When automatic recovery is enabled, connection errors are now logged as warnings
28
- and not errors.
29
-
30
- Contributed by Merten Falk.
31
-
32
- GitHub issue: [#531](https://github.com/ruby-amqp/bunny/pull/531)
33
-
34
-
35
- ## Changes between Bunny 2.7.1 and 2.7.2 (Nov 4th, 2017)
36
-
37
- ### Heartbeat Value Supports `:server` and `"server"`
38
-
39
- Heartbeat value of `:server` now can be specified as a string.
40
-
41
- Contributed by Tyrone.
42
-
43
-
44
- ### Reading a Frame without Payload Could Result in a `Bunny::NoFinalOctetError`
45
-
46
- Reading a frame without payload (e.g. a heartbeat frame) could result in a `Bunny::NoFinalOctetError`
47
- with mostly idle connections.
48
-
49
- GitHub issue: [#521](https://github.com/ruby-amqp/bunny/issues/521).
50
-
51
- Contributed by GPif.
52
-
53
-
54
- ## Changes between Bunny 2.7.0 and 2.7.1 (Sep 25th, 2017)
55
-
56
- ### Sensible Socket Read Timeouts When RabbitMQ is Configured to Disabled Heartbeats
57
-
58
- Bunny now correctly handles scenarios where server is configured
59
- to disable heartbeats (which is a terrible idea, don't do it!)
60
-
61
- GitHub issue: [#519](https://github.com/ruby-amqp/bunny/issues/519).
62
-
63
- ### Bunny::Channel#basic_get Usability
64
-
65
- `Bunny::Channel#basic_get` invoked with a non-existent queue now
66
- throws a channel exception instead of a generic operation timeout.
67
-
68
- GitHub issue: [#518](https://github.com/ruby-amqp/bunny/issues/518).
69
-
70
- ### Spec Suite Improvements
71
-
72
- `BUNNY_CERTIFICATE_DIR` environment variable now can be used
73
- to override local CA and client certificate/key pair directory.
74
- The directory is expected to be the result directory generated
75
- by the basic [tls-gen](http://github.com/michaelklishin/tls-gen) profile.
76
-
77
- TLSv1.0 is no longer used in tests because it's being disabled by default
78
- by more and more installations as it has known vulnerabilities
79
- and is no longer considered to be acceptable by several compliance
80
- standards (e.g. PCI DSS).
81
-
82
- ### Improved Synchronisation for channel.close Handlers
83
-
84
- `channel.close` handler will now acquire a lock . This avoids concurrency
85
- hazards in some rare scenarios when a channel is closed due a protocol
86
- exception by the server and concurrently opened by user code
87
- at the same time.
88
-
89
- ### More Meaningful Error Messages in Bunny::Session#create_channel
90
-
91
- Sometimes users attempt to open a channel on a connection that
92
- isn't connected yet because `Bunny::Session#start` was never invoked.
93
-
94
- `Bunny::Session#create_channel` will now provide a more sensible exception message
95
- in those cases.
96
-
97
-
98
- ## Changes between Bunny 2.6.0 and 2.7.0 (May 11th, 2017)
99
-
100
- ### amq-protocol Update
101
-
102
- Minimum `amq-protocol` version is now [`2.2.0`](https://github.com/ruby-amqp/amq-protocol/blob/master/ChangeLog.md#changes-between-210-and-220-may-11th-2017) which includes
103
- a change in [how timestamps are encoded](https://github.com/ruby-amqp/amq-protocol/issues/64).
104
-
105
-
106
- ### `Bunny::ContinuationQueue#poll` Less Prone to Race Conditions
107
-
108
- `Bunny::ContinuationQueue#poll` was reworked with feedback from Joseph Wong.
109
-
110
- GitHub issue: [#462](https://github.com/ruby-amqp/bunny/issues/462)
111
-
112
-
113
- ### Recovery Attempt Counting Strategy Changed
114
-
115
- Previous behehavior is not unreasonable but is not what many users and
116
- even RabbitMQ team members come to expect. Therefore it can be
117
- considered a bug.
118
-
119
- Previously a reconnection counter was preserved between successful
120
- recoveries. This made the integration test that uses server-sent
121
- connection.close possible.
122
-
123
- With this change, the counter is reset after successful reconnection
124
- but there's an option to go back to the original behavior. We also do
125
- a hell of a lot more logging.
126
-
127
- GitHub issue: [#408](https://github.com/ruby-amqp/bunny/issues/408)
128
-
129
-
130
- ### Absolute Windows File Paths are No Longer treated as Inline Certs
131
-
132
- Contributed by Jared Smartt.
133
-
134
- GitHub issue: [#492](https://github.com/ruby-amqp/bunny/issues/492).
135
-
136
-
137
- ### Opening a Channel on an Intentionally Closed Connection Immediately Raises an Exception
138
-
139
- Contributed by Alessandro Verlato.
140
-
141
- GitHub issue: [#465](https://github.com/ruby-amqp/bunny/issues/465)
142
-
143
-
144
- ### Bunny::ConsumerWorkPool#shutdown Terminates Early When It's Safe to Do So
145
-
146
- `Bunny::ConsumerWorkPool#shutdown(true)` waited for consumer shutdown
147
- even if the pool wasn't active (there were no consumers on its
148
- channel).
149
-
150
- GitHub issue: [#438](https://github.com/ruby-amqp/bunny/issues/438).
151
-
152
-
153
- ### Retry on new Ruby 2.1+ variations of `EAGAIN`, `EWOULDBLOCK`
154
-
155
- GitHub issue: [#456](https://github.com/ruby-amqp/bunny/issues/456)
156
-
157
-
158
- ### Do Not Modify Host Arrays
159
-
160
- Bunny now can work with frozen host arrays.
161
-
162
- GitHub issue: [#446](https://github.com/ruby-amqp/bunny/issues/446)
163
-
164
-
165
-
166
- ## Changes between Bunny 2.5.0 and 2.6.0 (October 15th, 2016)
167
-
168
- ### Graceful Shutdown of Consumers
169
-
170
- Consumer work pool will now allow for a grace period before stopping
171
- pool threads so that delivery processing in progress can have a chance to finish.
172
-
173
- GitHub issue: [#437](https://github.com/ruby-amqp/bunny/pull/437)
174
-
175
- Contributed by Stefan Sedich.
176
-
177
- ### `Bunny::Channel#wait_for_confirms` Now Throws When Used on a Closed Channel
178
-
179
- GitHub issue: [#428](https://github.com/ruby-amqp/bunny/pull/428)
180
-
181
- Contributed by Dimitar Dimitrov.
182
-
183
- ### Race Condition Eliminated in `Bunny::Channel#wait_for_confirms`
184
-
185
- GitHub issue: [#424](https://github.com/ruby-amqp/bunny/issues/424)
186
-
187
- Contributed by Dimitar Dimitrov.
188
-
189
- ### More Defensive Consumer Work Pool
190
-
191
- `Bunny::ConsumerWorkPool#join` and `Bunny::ConsumerWorkPool#pause`
192
- no longer fails with a `NoMethodError` on nil when executed
193
- on a work pool that doesn't have active threads (consumers).
194
-
195
- This change is largely cosmetic and won't affect the majority
196
- of of projects in any way.
197
-
198
-
199
- ## Changes between Bunny 2.4.0 and 2.5.0 (July 20th, 2016)
200
-
201
- ### Exchange Bindings are Now Correctly Recovered
202
-
203
- GitHub issue: [#410](https://github.com/ruby-amqp/bunny/issues/410)
204
-
205
- Contributed by Andrew Bruce.
206
-
207
-
208
- ### `Bunny::Channel#wait_for_confirms` Awaits While There're Outstanding Unconfirmed Messages
209
-
210
- GitHub issue: [#424](https://github.com/ruby-amqp/bunny/issues/424)
211
-
212
- Contributed by Dimitar Dimitrov.
213
-
214
-
215
- ### Queue Recovery Respects the `:no_declare` Option
216
-
217
- Queue recovery now respects the `:no_declare` option.
218
-
219
-
220
- ### `Bunny::Channel#wait_for_confirms` Throws Early
221
-
222
- `Bunny::Channel#wait_for_confirms` now throws an exception
223
- early when invoked on a closed channel.
224
-
225
- GitHub issue: [#428](https://github.com/ruby-amqp/bunny/pull/428).
226
-
227
- Contributed by Dimitar Dimitrov.
228
-
229
-
230
-
231
- ## Changes between Bunny 2.3.0 and 2.4.0 (June 11th, 2016)
232
-
233
- **This release includes minor breaking API changes**.
234
-
235
- ### Unconfirmed Delivery Tag Set Reset on Network Recovery
236
-
237
- Channels will now reset their unconfirmed delivery tag set after
238
- recovery.
239
-
240
- GitHub issue: [#406](https://github.com/ruby-amqp/bunny/pull/406)
241
-
242
- Contributed by Bill Ruddock.
243
-
244
- ### Support (Quoted) IPv6 Addresses in Address Lists
245
-
246
- GitHub issue: [#383](https://github.com/ruby-amqp/bunny/issues/383).
247
-
248
- Contributed by Jeremy Heiler.
249
-
250
- ### Transport#read_fully Doesn't Try to Recover
251
-
252
- Since transport is replaced by a recovering connection
253
- anyway, and this produces confusing errors up the stack.
254
-
255
- GitHub issue: [#359](https://github.com/ruby-amqp/bunny/issues/359)
256
-
257
- Contributed by Donal McBreen.
258
-
259
- ### Client-Provided Session `:properties` Merged with Defaults
260
-
261
- Client-Provided Session `:properties` will now be merged with defaults
262
- instead of replacing them. This makes it much more convenient to
263
- override a single key.
264
-
265
- ### More Predictable RABBITMQ_URL Handling
266
-
267
- **This is a breaking API change**.
268
-
269
- `RABBITMQ_URL` no longer will be used if any other
270
- connection options are provided. This makes it possible
271
- to use `RABBITMQ_URL` for some connections and options
272
- for others in a single OS process.
273
-
274
- GitHub issue: [#403](https://github.com/ruby-amqp/bunny/pull/403)
275
-
276
- Contributed by Jimmy Petersen.
277
-
278
-
279
- ## Changes between Bunny 2.2.0 and 2.3.0 (Feb 26th, 2016)
280
-
281
- ### Thread#abort_on_exception Setting for Consumer Work Pool Threads
282
-
283
- `Bunny::Session#create_channel` now supports a 3rd argument that,
284
- when set to `true`, makes consumer work pool threads to have
285
- `Thread#abort_on_exception` set on them.
286
-
287
- GH issue: [#382](https://github.com/ruby-amqp/bunny/pull/382)
288
-
289
- Contributed by Seamus Abshere.
290
-
291
- ### Explicit Transport Closure on Recovery
292
-
293
- Bunny now will explicitly close previosly used transport before starting
294
- connection recovery.
295
-
296
- GitHub issue: [#377](https://github.com/ruby-amqp/bunny/pull/377).
297
-
298
- Contributed by bkanhoopla.
299
-
300
- ### No TLS Socket Double-init
301
-
302
- Makes sure that TLS sockets are not double-initialized.
303
-
304
- GH issue: [#345](https://github.com/ruby-amqp/bunny/issues/345).
305
-
306
- Contributed by Carl Hörberg.
307
-
308
- ### Lazily Evaluated Debug Log Strings
309
-
310
- GH issue: [#375](https://github.com/ruby-amqp/bunny/pull/375)
311
-
312
- Contributed by Omer Katz.
313
-
314
-
315
-
316
- ## Changes between Bunny 2.1.0 and 2.2.0 (Sep 6th, 2015)
317
-
318
- ### Add :addresses to connect options
319
-
320
- Before this the connection options only allowed multiple hosts, an
321
- address is a combination of a host and a port. This makes it possible to
322
- specify different hosts with different ports.
323
-
324
- Contributed by Bart van Zon (Tele2).
325
-
326
- ### Recover from connection.close by default
327
-
328
- Bunny will now try to reconnect also when server sent connection.close is
329
- received, e.g. when a server is restarting (but also when the connection is
330
- force closed by the server). This is in-line with how many other clients behave.
331
- The old default was `recover_from_connection_close: false`.
332
-
333
- Contributed by Carl Hörberg (CloudAMQP).
334
-
335
-
336
- ## Changes between Bunny 2.0.0 and 2.1.0
337
-
338
- Bunny 2.1.0 has an **important breaking change**. It is highly
339
- advised that 2.1.0 is not mixed with earlier versions of Bunny
340
- in case your applications include **integers in message headers**.
341
-
342
- ### Integer Value Serialisation in Headers
343
-
344
- Integer values in headers are now serialised as signed 64-bit integers. Previously
345
- they were serialised as 32-bit unsigned integers, causing both underflows
346
- and overflows: incorrect values were observed by consumers.
347
-
348
- It is highly
349
- advised that 2.1.0 is not mixed with earlier versions of Bunny
350
- in case your applications include integers in message headers.
351
-
352
- If that's not the case, Bunny 2.1 will integeroperate with any earlier version
353
- starting with 0.9.0 just fine. Popular clients in other languages
354
- (e.g. Java and .NET) will interoperate with Bunny 2.1.0 without
355
- issues.
356
-
357
-
358
- ### Explicit Ruby 2.0 Requirement
359
-
360
- Bunny now requires Ruby 2.0 in the gemspec.
361
-
362
- Contributed by Carl Hörberg.
363
-
364
- ### JRuby Fix
365
-
366
- Bunny runs again on JRuby. Note that
367
- JRuby users are strongly advised to use March Hare instead.
368
-
369
- Contributed by Teodor Pripoae.
370
-
371
-
372
-
373
- ## Changes between Bunny 1.7.0 and 2.0.0
374
-
375
- Bunny `2.0` doesn't have any breaking API changes
376
- but drops Ruby 1.8 and 1.9 (both EOL'ed) support,
377
- hence the version.
378
-
379
- ### Minimum Required Ruby Version is 2.0
380
-
381
- Bunny `2.0` requires Ruby 2.0 or later.
382
-
383
- ## Non-Blocking Writes
384
-
385
- Bunny now uses non-blocking socket writes, uses a reduced
386
- number of writes for message publishing (frames are batched
387
- into a single write), and handles TCP back pressure from
388
- RabbitMQ better.
389
-
390
- Contributed by Irina Bednova and Michael Klishin.
391
-
392
- ### Reduced Timeout Use
393
-
394
- `Bunny::ContinuationQueue#poll` no longer relies on Ruby's `Timeout` which has
395
- numerous issues, including starting a new "interruptor" thread per operation,
396
- which is far from efficient.
397
-
398
- Contributed by Joe Eli McIlvain and Carl Hörberg.
399
-
400
- ### Capped Number of Connection Recovery Attempts
401
-
402
- `:recovery_attempts` is a new option that limits the number of
403
- connection recovery attempts performed by Bunny. `nil` means
404
- "no limit".
405
-
406
- Contributed by Irina Bednova.
407
-
408
- ### Bunny::Channel#basic_ack and Related Methods Improvements
409
-
410
- `Bunny::Channel#basic_ack`, `Bunny::Channel#basic_nack`, and `Bunny::Channel#basic_reject`
411
- now adjust delivery tags between connection recoveries, as well as have a default value for
412
- the second argument.
413
-
414
- Contributed by Wayne Conrad.
415
-
416
- ### Logger Output Remains Consistent
417
-
418
- Setting the `@logger.progname` attribute changes the output of the logger.
419
- This is not expected behaviour when the client provides a custom logger.
420
- Behaviour remains unchainged when the internally initialized logger is used.
421
-
422
- Contributed by Justin Carter.
423
-
424
- ### prefetch_count is Limited to 65535
425
-
426
- Since `basic.qos`'s `prefetch_count` field is of type `short` in the protocol,
427
- Bunny must enforce its maximum allowed value to `2^16 - 1` to avoid
428
- confusing issues due to overflow.
429
-
430
- ### Per-Consumer and Per-Channel Prefetch
431
-
432
- Recent RabbitMQ versions support `basic.qos` `global` flag, controlling whether
433
- `prefetch` applies per-consumer or per-channel. Bunny `Channel#prefetch` now
434
- allows flag to be set as optional parameter, with the same default behaviour as
435
- before (per-consumer).
436
-
437
- Contributed by tiredpixel.
438
-
439
-
440
- ## Changes between Bunny 1.6.0 and 1.7.0
441
-
442
- ### TLS Peer Verification Enabled by Default
443
-
444
- When using TLS, peer verification is now enabled by default.
445
- It is still possible to [disable verification](http://rubybunny.info/articles/tls.html), e.g. for convenient
446
- development locally.
447
-
448
- Peer verification is a means of protection against man-in-the-middle attacks
449
- and is highly recommended in production settings. However, it can be an inconvenience
450
- during local development. We believe it's time to have the default to be
451
- more secure.
452
-
453
- Contributed by Michael Klishin (Pivotal) and Andre Foeken (Nedap).
454
-
455
-
456
- ### Higher Default Connection Timeout
457
-
458
- Default connection timeout has been increased to 25 seconds. The older
459
- default of 5 seconds wasn't sufficient in some edge cases with DNS
460
- resolution (e.g. when primary DNS server is down).
461
-
462
- The value can be overriden at connection time.
463
-
464
- Contributed by Yury Batenko.
465
-
466
-
467
- ### Socket Read Timeout No Longer Set to 0 With Disabled Heartbeats
468
-
469
- GH issue: [#267](https://github.com/ruby-amqp/bunny/pull/267).
470
-
471
-
472
- ### JRuby Writes Fixes
473
-
474
- On JRuby, Bunny reverts back to using plain old `write(2)` for writes. The CRuby implementation
475
- on JRuby suffers from I/O incompatibilities. Until JRuby
476
-
477
- Bunny users who run on JRuby are highly recommended to switch to [March Hare](http://rubymarchhare.info),
478
- which has nearly identical API and is significantly more efficient.
479
-
480
-
481
- ### Bunny::Session#with_channel Synchornisation Improvements
482
-
483
- `Bunny::Session#with_channel` is now fully synchronised and won't run into `COMMAND_INVALID` errors
484
- when used from multiple threads that share a connection.
485
-
486
-
487
-
488
- ## Changes between Bunny 1.5.0 and 1.6.0
489
-
490
- ### TLSv1 by Default
491
-
492
- TLS connections now prefer TLSv1 (or later, if available) due to the recently discovered
493
- [POODLE attack](https://www.openssl.org/~bodo/ssl-poodle.pdf) on SSLv3.
494
-
495
- Contributed by Michael Klishin (Pivotal) and Justin Powers (Desk.com).
496
-
497
- GH issues:
498
-
499
- * [#259](https://github.com/ruby-amqp/bunny/pull/259)
500
- * [#260](https://github.com/ruby-amqp/bunny/pull/260)
501
- * [#261](https://github.com/ruby-amqp/bunny/pull/261)
502
-
503
-
504
- ### Socket Read and Write Timeout Improvements
505
-
506
- Bunny now sets a read timeout on the sockets it opens, and uses
507
- `IO.select` timeouts as the most reliable option available
508
- on Ruby 1.9 and later.
509
-
510
- GH issue: [#254](https://github.com/ruby-amqp/bunny/pull/254).
511
-
512
- Contributed by Andre Foeken (Nedap).
513
-
514
- ### Inline TLS Certificates Support
515
-
516
- TLS certificate options now accept inline certificates as well as
517
- file paths.
518
-
519
- GH issues: [#255](https://github.com/ruby-amqp/bunny/pull/255), [#256](https://github.com/ruby-amqp/bunny/pull/256).
520
-
521
- Contributed by Will Barrett (Sqwiggle).
522
-
523
-
524
- ## Changes between Bunny 1.4.0 and 1.5.0
525
-
526
- ### Improved Uncaught Exception Handler
527
-
528
- Uncaught exception handler now provides more information about the exception,
529
- including its caller (one more stack trace line).
530
-
531
- Contributed by Carl Hörberg (CloudAMQP).
532
-
533
-
534
- ### Convenience Method for Temporary (Server-named, Exclusive) Queue Declaration
535
-
536
- `Bunny::Channel#temporary_queue` is a convenience method that declares a new
537
- server-named exclusive queue:
538
-
539
- ``` ruby
540
- q = ch.temporary_queue
541
- ```
542
-
543
- Contributed by Daniel Schierbeck (Zendesk).
544
-
545
- ### Recovery Reliability Improvements
546
-
547
- Automatic connection recovery robustness improvements.
548
- Contributed by Andre Foeken (Nedap).
549
-
550
- ### Host Lists
551
-
552
- It is now possible to pass the `:hosts` option to `Bunny.new`/`Bunny::Session#initialize`.
553
- When connection to RabbitMQ (including during connection recovery), a random host
554
- will be chosen from the list.
555
-
556
- Connection shuffling and robustness improvements.
557
-
558
- Contributed by Andre Foeken (Nedap).
559
-
560
- ### Default Channel Removed
561
-
562
- Breaks compatibility with Bunny 0.8.x.
563
-
564
- `Bunny:Session#default_channel` was removed. Please open channels explicitly now,
565
- as all the examples in the docs do.
566
-
567
-
568
- ## Changes between Bunny 1.3.0 and 1.4.0
569
-
570
- ### Channel#wait_for_confirms Returns Immediately If All Publishes Confirmed
571
-
572
- Contributed by Matt Campbell.
573
-
574
- ### Publisher Confirms is In Sync After Recovery
575
-
576
- When a connection is recovered, the sequence counter resets on the
577
- broker, but not the client. To keep things in sync the client must store a confirmation
578
- offset after a recovery.
579
-
580
- Contributed by Devin Christensen.
581
-
582
- ### NoMethodError on Thread During Shutdown
583
-
584
- During abnormal termination, `Bunny::Session#close` no longer tries
585
- to call the non-existent `terminate_with` method on its origin
586
- thread.
587
-
588
-
589
- ## Changes between Bunny 1.2.0 and 1.3.0
590
-
591
- ### TLS Can Be Explicitly Disabled
592
-
593
- TLS now can be explicitly disabled even when connecting (without TLS)
594
- to the default RabbitMQ TLS/amqps port (5671):
595
-
596
- ``` ruby
597
- conn = Bunny.new(:port => 5671, :tls => false)
598
- ```
599
-
600
- Contributed by Muhan Zou.
601
-
602
-
603
- ### Single Threaded Connections Raise Shutdown Exceptions
604
-
605
- Single threaded Bunny connections will now raise exceptions
606
- that occur during shutdown as is (instead of trying to shut down
607
- I/O loop which only threaded ones have).
608
-
609
- Contributed by Carl Hörberg.
610
-
611
-
612
- ### Synchronization Improvements for Session#close
613
-
614
- `Bunny::Session#close` now better synchronizes state transitions,
615
- eliminating a few race condition scenarios with I/O reader thread.
616
-
617
-
618
- ### Bunny::Exchange.default Fix
619
-
620
- `Bunny::Exchange.default` no longer raises an exception.
621
-
622
- Note that it is a legacy compatibility method. Please use
623
- `Bunny::Channel#default_exchange` instead.
624
-
625
- Contributed by Justin Litchfield.
626
-
627
- GH issue [#211](https://github.com/ruby-amqp/bunny/pull/211).
628
-
629
- ### Bunny::Queue#pop_as_hash Removed
630
-
631
- `Bunny::Queue#pop_as_hash`, which was added to ease migration
632
- to Bunny 0.9, was removed.
633
-
634
- ### Bunny::Queue#pop Wraps Metadata
635
-
636
- `Bunny::Queue#pop` now wraps `basic.get-ok` and message properties
637
- into `Bunny::GetResponse` and `Bunny::MessageProperties`, just like
638
- `basic.consume` deliveries.
639
-
640
- GH issue: [#212](https://github.com/ruby-amqp/bunny/issues/212).
641
-
642
- ### Better Synchronization for Publisher Confirms
643
-
644
- Publisher confirms implementation now synchronizes unconfirmed
645
- set better.
646
-
647
- Contributed by Nicolas Viennot.
648
-
649
- ### Channel Allocation After Recovery
650
-
651
- Channel id allocator is no longer reset after recovery
652
- if there are channels open. Makes it possible to open channels
653
- on a recovered connection (in addition to the channels
654
- it already had).
655
-
656
-
657
-
658
- ## Changes between Bunny 1.1.0 and 1.2.0
659
-
660
- ### :key Supported in Bunny::Channel#queue_bind
661
-
662
- It is now possible to use `:key` (which Bunny versions prior to 0.9 used)
663
- as well as `:routing_key` as an argument to `Bunny::Queue#bind`.
664
-
665
- ### System Exceptions Not Rescued by the Library
666
-
667
- Bunny now rescues `StandardError` instead of `Exception` where
668
- it automatically does so (e.g. when dispatching deliveries to consumers).
669
-
670
- Contributed by Alex Young.
671
-
672
-
673
- ### Initial Socket Connection Timeout Again Raises Bunny::TCPConnectionFailed
674
-
675
- Initial socket connection timeout again raises `Bunny::TCPConnectionFailed`
676
- on the connection origin thread.
677
-
678
- ### Thread Leaks Plugged
679
-
680
- `Bunny::Session#close` on connections that have experienced a network failure
681
- will correctly clean up I/O and heartbeat sender threads.
682
-
683
- Contributed by m-o-e.
684
-
685
- ### Bunny::Concurrent::ContinuationQueue#poll Rounding Fix
686
-
687
- `Bunny::Concurrent::ContinuationQueue#poll` no longer floors the argument
688
- to the nearest second.
689
-
690
- Contributed by Brian Abreu.
691
-
692
- ### Routing Key Limit
693
-
694
- Per AMQP 0-9-1 spec, routing keys cannot be longer than 255 characters.
695
- `Bunny::Channel#basic_publish` and `Bunny::Exchange#publish` now enforces
696
- this limit.
697
-
698
- ### Nagle's Algorithm Disabled Correctly
699
-
700
- Bunny now properly disables [Nagle's algorithm](http://boundary.com/blog/2012/05/02/know-a-delay-nagles-algorithm-and-you/)
701
- on the sockets it opens. This likely means
702
- significantly lower latency for workloads that involve
703
- sending a lot of small messages very frequently.
704
-
705
- [Contributed](https://github.com/ruby-amqp/bunny/pull/187) by Nelson Gauthier (AirBnB).
706
-
707
- ### Internal Exchanges
708
-
709
- Exchanges now can be declared as internal:
710
-
711
- ``` ruby
712
- ch = conn.create_channel
713
- x = ch.fanout("bunny.tests.exchanges.internal", :internal => true)
714
- ```
715
-
716
- Internal exchanges cannot be published to by clients and are solely used
717
- for [Exchange-to-Exchange bindings](http://rabbitmq.com/e2e.html) and various
718
- plugins but apps may still need to bind them. Now it is possible
719
- to do so with Bunny.
720
-
721
- ### Uncaught Consumer Exceptions
722
-
723
- Uncaught consumer exceptions are now handled by uncaught exceptions
724
- handler that can be defined per channel:
725
-
726
- ``` ruby
727
- ch.on_uncaught_exception do |e, consumer|
728
- # ...
729
- end
730
- ```
731
-
732
-
733
-
734
- ## Changes between Bunny 1.1.0.rc1 and 1.1.0
735
-
736
- ### Synchronized Session#create_channel and Session#close_channel
737
-
738
- Full bodies of `Bunny::Session#create_channel` and `Bunny::Session#close_channel`
739
- are now synchronized, which makes sure concurrent `channel.open` and subsequent
740
- operations (e.g. `exchange.declare`) do not result in connection-level exceptions
741
- (incorrect connection state transitions).
742
-
743
- ### Corrected Recovery Log Message
744
-
745
- Bunny will now use actual recovery interval in the log.
746
-
747
- Contributed by Chad Fowler.
748
-
749
-
750
-
751
-
752
- ## Changes between Bunny 1.1.0.pre2 and 1.1.0.rc1
753
-
754
- ### Full Channel State Recovery
755
-
756
- Channel recovery now involves recovery of publisher confirms and
757
- transaction modes.
758
-
759
-
760
- ### TLS Without Peer Verification
761
-
762
- Bunny now successfully performs TLS upgrade when peer verification
763
- is disabled.
764
-
765
- Contributed by Jordan Curzon.
766
-
767
- ### Bunny::Session#with_channel Ensures the Channel is Closed
768
-
769
- `Bunny::Session#with_channel` now makes sure the channel is closed
770
- even if provided block raises an exception
771
-
772
- Contributed by Carl Hoerberg.
773
-
774
-
775
-
776
- ### Channel Number = 0 is Rejected
777
-
778
- `Bunny::Session#create_channel` will now reject channel number 0.
779
-
780
-
781
- ### Single Threaded Mode Fixes
782
-
783
- Single threaded mode no longer fails with
784
-
785
- ```
786
- undefined method `event_loop'
787
- ```
788
-
789
-
790
-
791
- ## Changes between Bunny 1.1.0.pre1 and 1.1.0.pre2
792
-
793
- ### connection.tune.channel_max No Longer Overflows
794
-
795
- `connection.tune.channel_max` could previously be configured to values
796
- greater than 2^16 - 1 (65535). This would result in a silent overflow
797
- during serialization. The issue was harmless in practice but is still
798
- a bug that can be quite confusing.
799
-
800
- Bunny now caps max number of channels to 65535. This allows it to be
801
- forward compatible with future RabbitMQ versions that may allow limiting
802
- total # of open channels via server configuration.
803
-
804
- ### amq-protocol Update
805
-
806
- Minimum `amq-protocol` version is now `1.9.0` which includes
807
- bug fixes and performance improvements for channel ID allocator.
808
-
809
- ### Thread Leaks Fixes
810
-
811
- Bunny will now correctly release heartbeat sender when allocating
812
- a new one (usually happens only when connection recovers from a network
813
- failure).
814
-
815
-
816
- ## Changes between Bunny 1.0.0 and 1.1.0.pre1
817
-
818
- ### Versioned Delivery Tag Fix
819
-
820
- Versioned delivery tag now ensures all the arguments it operates
821
- (original delivery tag, atomic fixnum instances, etc) are coerced to `Integer`
822
- before comparison.
823
-
824
- GitHub issues: #171.
825
-
826
- ### User-Provided Loggers
827
-
828
- Bunny now can use any logger that provides the same API as Ruby standard library's `Logger`:
829
-
830
- ``` ruby
831
- require "logger"
832
- require "stringio"
833
-
834
- io = StringIO.new
835
- # will log to `io`
836
- Bunny.new(:logger => Logger.new(io))
837
- ```
838
-
839
- ### Default CA's Paths Are Disabled on JRuby
840
-
841
- Bunny uses OpenSSL provided CA certificate paths. This
842
- caused problems on some platforms on JRuby (see [jruby/jruby#155](https://github.com/jruby/jruby/issues/1055)).
843
-
844
- To avoid these issues, Bunny no longer uses default CA certificate paths on JRuby
845
- (there are no changes for other Rubies), so it's necessary to provide
846
- CA certificate explicitly.
847
-
848
- ### Fixes CPU Burn on JRuby
849
-
850
- Bunny now uses slightly different ways of continuously reading from the socket
851
- on CRuby and JRuby, to prevent abnormally high CPU usage on JRuby after a
852
- certain period of time (the frequency of `EWOULDBLOCK` being raised spiked
853
- sharply).
854
-
855
-
856
-
857
- ## Changes between Bunny 1.0.0.rc2 and 1.0.0.rc3
858
-
859
- ### [Authentication Failure Notification](http://www.rabbitmq.com/auth-notification.html) Support
860
-
861
- `Bunny::AuthenticationFailureError` is a new auth failure exception
862
- that subclasses `Bunny::PossibleAuthenticationFailureError` for
863
- backwards compatibility.
864
-
865
- As such, `Bunny::PossibleAuthenticationFailureError`'s error message
866
- has changed.
867
-
868
- This extension is available in RabbitMQ 3.2+.
869
-
870
-
871
- ### Bunny::Session#exchange_exists?
872
-
873
- `Bunny::Session#exchange_exists?` is a new predicate that makes it
874
- easier to check if a exchange exists.
875
-
876
- It uses a one-off channel and `exchange.declare` with `passive` set to true
877
- under the hood.
878
-
879
- ### Bunny::Session#queue_exists?
880
-
881
- `Bunny::Session#queue_exists?` is a new predicate that makes it
882
- easier to check if a queue exists.
883
-
884
- It uses a one-off channel and `queue.declare` with `passive` set to true
885
- under the hood.
886
-
887
-
888
- ### Inline TLS Certificates and Keys
889
-
890
- It is now possible to provide inline client
891
- certificate and private key (as strings) instead
892
- of filesystem paths. The options are the same:
893
-
894
- * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
895
- * `:tls_cert` which now can be a client certificate (public key) in PEM format
896
- * `:tls_key` which now can be a client key (private key) in PEM format
897
- * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
898
-
899
- For example:
900
-
901
- ``` ruby
902
- conn = Bunny.new(:tls => true,
903
- :tls_cert => ENV["TLS_CERTIFICATE"],
904
- :tls_key => ENV["TLS_PRIVATE_KEY"],
905
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
906
- ```
907
-
908
-
909
-
910
- ## Changes between Bunny 1.0.0.rc1 and 1.0.0.rc2
911
-
912
- ### Ruby 1.8.7 Compatibility Fixes
913
-
914
- Ruby 1.8.7 compatibility fixes around timeouts.
915
-
916
-
917
-
918
- ## Changes between Bunny 1.0.0.pre6 and 1.0.0.rc1
919
-
920
- ### amq-protocol Update
921
-
922
- Minimum `amq-protocol` version is now `1.8.0` which includes
923
- a bug fix for messages exactly 128 Kb in size.
924
-
925
-
926
- ### Add timeout Bunny::ConsumerWorkPool#join
927
-
928
- `Bunny::ConsumerWorkPool#join` now accepts an optional
929
- timeout argument.
930
-
931
-
932
- ## Changes between Bunny 1.0.0.pre5 and 1.0.0.pre6
933
-
934
- ### Respect RABBITMQ_URL value
935
-
936
- `RABBITMQ_URL` env variable will now have effect even if
937
- Bunny.new is invoked without arguments.
938
-
939
-
940
-
941
- ## Changes between Bunny 1.0.0.pre4 and 1.0.0.pre5
942
-
943
- ### Ruby 1.8 Compatibility
944
-
945
- Bunny is Ruby 1.8-compatible again and no longer references
946
- `RUBY_ENGINE`.
947
-
948
- ### Bunny::Session.parse_uri
949
-
950
- `Bunny::Session.parse_uri` is a new method that parses
951
- connection URIs into hashes that `Bunny::Session#initialize`
952
- accepts.
953
-
954
- ``` ruby
955
- Bunny::Session.parse_uri("amqp://user:pwd@broker.eng.megacorp.local/myapp_qa")
956
- ```
957
-
958
- ### Default Paths for TLS/SSL CA's on All OS'es
959
-
960
- Bunny now uses OpenSSL to detect default TLS/SSL CA's paths, extending
961
- this feature to OS'es other than Linux.
962
-
963
- Contributed by Jingwen Owen Ou.
964
-
965
-
966
- ## Changes between Bunny 1.0.0.pre3 and 1.0.0.pre4
967
-
968
- ### Default Paths for TLS/SSL CA's on Linux
969
-
970
- Bunny now will use the following TLS/SSL CA's paths on Linux by default:
971
-
972
- * `/etc/ssl/certs/ca-certificates.crt` on Ubuntu/Debian
973
- * `/etc/ssl/certs/ca-bundle.crt` on Amazon Linux
974
- * `/etc/ssl/ca-bundle.pem` on OpenSUSE
975
- * `/etc/pki/tls/certs/ca-bundle.crt` on Fedora/RHEL
976
-
977
- and will log a warning if no CA files are available via default paths
978
- or `:tls_ca_certificates`.
979
-
980
- Contributed by Carl Hörberg.
981
-
982
- ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
983
-
984
- It is now possible to re-register a consumer (and use any other synchronous methods)
985
- from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
986
- thread pool.
987
-
988
-
989
- ### Bunny::Session#close Fixed for Single Threaded Connections
990
-
991
- `Bunny::Session#close` with single threaded connections no longer fails
992
- with a nil pointer exception.
993
-
994
-
995
-
996
- ## Changes between Bunny 1.0.0.pre2 and 1.0.0.pre3
997
-
998
- This release has **breaking API changes**.
999
-
1000
- ### Safe[r] basic.ack, basic.nack and basic.reject implementation
1001
-
1002
- Previously if a channel was recovered (reopened) by automatic connection
1003
- recovery before a message was acknowledged or rejected, it would cause
1004
- any operation on the channel that uses delivery tags to fail and
1005
- cause the channel to be closed.
1006
-
1007
- To avoid this issue, every channel keeps a counter of how many times
1008
- it has been reopened and marks delivery tags with them. Using a stale
1009
- tag to ack or reject a message will produce no method sent to RabbitMQ.
1010
- Note that unacknowledged messages will be requeued by RabbitMQ when connection
1011
- goes down anyway.
1012
-
1013
- This involves an API change: `Bunny::DeliveryMetadata#delivery_tag` is now
1014
- and instance of a class that responds to `#tag` and `#to_i` and is accepted
1015
- by `Bunny::Channel#ack` and related methods.
1016
-
1017
- Integers are still accepted by the same methods.
1018
-
1019
-
1020
- ## Changes between Bunny 1.0.0.pre1 and 1.0.0.pre2
1021
-
1022
- ### Exclusivity Violation for Consumers Now Raises a Reasonable Exception
1023
-
1024
- When a second consumer is registered for the same queue on different channels,
1025
- a reasonable exception (`Bunny::AccessRefused`) will be raised.
1026
-
1027
-
1028
- ### Reentrant Mutex Implementation
1029
-
1030
- Bunny now allows mutex impl to be configurable, uses reentrant Monitor
1031
- by default.
1032
-
1033
- Non-reentrant mutexes is a major PITA and may affect code that
1034
- uses Bunny.
1035
-
1036
- Avg. publishing throughput with Monitor drops slightly from
1037
- 5.73 Khz to 5.49 Khz (about 4% decrease), which is reasonable
1038
- for Bunny.
1039
-
1040
- Apps that need these 4% can configure what mutex implementation
1041
- is used on per-connection basis.
1042
-
1043
- ### Eliminated Race Condition in Bunny::Session#close
1044
-
1045
- `Bunny::Session#close` had a race condition that caused (non-deterministic)
1046
- exceptions when connection transport was closed before connection
1047
- reader loop was guaranteed to have stopped.
1048
-
1049
- ### connection.close Raises Exceptions on Connection Thread
1050
-
1051
- Connection-level exceptions (including when a connection is closed via
1052
- management UI or `rabbitmqctl`) will now be raised on the connection
1053
- thread so they
1054
-
1055
- * can be handled by applications
1056
- * do not start connection recovery, which may be uncalled for
1057
-
1058
- ### Client TLS Certificates are Optional
1059
-
1060
- Bunny will no longer require client TLS certificates. Note that CA certificate
1061
- list is still necessary.
1062
-
1063
- If RabbitMQ TLS configuration requires peer verification, client certificate
1064
- and private key are mandatory.
1065
-
1066
-
1067
- ## Changes between Bunny 0.9.0 and 1.0.0.pre1
1068
-
1069
- ### Publishing Over Closed Connections
1070
-
1071
- Publishing a message over a closed connection (during a network outage, before the connection
1072
- is open) will now correctly result in an exception.
1073
-
1074
- Contributed by Matt Campbell.
1075
-
1076
-
1077
- ### Reliability Improvement in Automatic Network Failure Recovery
1078
-
1079
- Bunny now ensures a new connection transport (socket) is initialized
1080
- before any recovery is attempted.
1081
-
1082
-
1083
- ### Reliability Improvement in Bunny::Session#create_channel
1084
-
1085
- `Bunny::Session#create_channel` now uses two separate mutexes to avoid
1086
- a (very rare) issue when the previous implementation would try to
1087
- re-acquire the same mutex and fail (Ruby mutexes are non-reentrant).
1088
-
1089
-
1090
-
1091
- ## Changes between Bunny 0.9.0.rc1 and 0.9.0.rc2
1092
-
1093
- ### Channel Now Properly Restarts Consumer Pool
1094
-
1095
- In a case when all consumers are cancelled, `Bunny::Channel`
1096
- will shut down its consumer delivery thread pool.
1097
-
1098
- It will also now mark the pool as not running so that it can be
1099
- started again successfully if new consumers are registered later.
1100
-
1101
- GH issue: #133.
1102
-
1103
-
1104
- ### Bunny::Queue#pop_waiting is Removed
1105
-
1106
- A little bit of background: on MRI, the method raised `ThreadErrors`
1107
- reliably. On JRuby, we used a different [internal] queue implementation
1108
- from JDK so it wasn't an issue.
1109
-
1110
- `Timeout.timeout` uses `Thread#kill` and `Thread#join`, both of which
1111
- eventually attempt to acquire a mutex used by Queue#pop, which Bunny
1112
- currently uses for continuations. The mutex is already has an owner
1113
- and so a ThreadError is raised.
1114
-
1115
- This is not a problem on JRuby because there we don't use Ruby's
1116
- Timeout and Queue and instead rely on a JDK concurrency primitive
1117
- which provides "poll with a timeout".
1118
-
1119
- [The issue with `Thread#kill` and `Thread#raise`](http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html)
1120
- has been first investigated and blogged about by Ruby implementers
1121
- in 2008.
1122
-
1123
- Finding a workaround will probably take a bit of time and may involve
1124
- reimplementing standard library and core classes.
1125
-
1126
- We don't want this issue to block Bunny 0.9 release. Neither we want
1127
- to ship a broken feature. So as a result, we will drop
1128
- Bunny::Queue#pop_waiting since it cannot be reliably implemented in a
1129
- reasonable amount of time on MRI.
1130
-
1131
- Per issue #131.
1132
-
1133
-
1134
- ### More Flexible SSLContext Configuration
1135
-
1136
- Bunny will now upgrade connection to SSL in `Bunny::Session#start`,
1137
- so it is possible to fine tune SSLContext and socket settings
1138
- before that:
1139
-
1140
- ``` ruby
1141
- require "bunny"
1142
-
1143
- conn = Bunny.new(:tls => true,
1144
- :tls_cert => "examples/tls/client_cert.pem",
1145
- :tls_key => "examples/tls/client_key.pem",
1146
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
1147
-
1148
- puts conn.transport.socket.inspect
1149
- puts conn.transport.tls_context.inspect
1150
- ```
1151
-
1152
- This also means that `Bunny.new` will now open the socket. Previously
1153
- it was only done when `Bunny::Session#start` was invoked.
1154
-
1155
-
1156
- ## Changes between Bunny 0.9.0.pre13 and 0.9.0.rc1
1157
-
1158
- ### TLS Support
1159
-
1160
- Bunny 0.9 finally supports TLS. There are 3 new options `Bunny.new` takes:
1161
-
1162
- * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
1163
- * `:tls_cert` which is a string path to the client certificate (public key) in PEM format
1164
- * `:tls_key` which is a string path to the client key (private key) in PEM format
1165
- * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
1166
-
1167
- An example:
1168
-
1169
- ``` ruby
1170
- conn = Bunny.new(:tls => true,
1171
- :tls_cert => "examples/tls/client_cert.pem",
1172
- :tls_key => "examples/tls/client_key.pem",
1173
- :tls_ca_certificates => ["./examples/tls/cacert.pem"])
1174
- ```
1175
-
1176
-
1177
- ### Bunny::Queue#pop_waiting
1178
-
1179
- **This function was removed in v0.9.0.rc2**
1180
-
1181
- `Bunny::Queue#pop_waiting` is a new function that mimics `Bunny::Queue#pop`
1182
- but will wait until a message is available. It uses a `:timeout` option and will
1183
- raise an exception if the timeout is hit:
1184
-
1185
- ``` ruby
1186
- # given 1 message in the queue,
1187
- # works exactly as Bunny::Queue#get
1188
- q.pop_waiting
1189
-
1190
- # given no messages in the queue, will wait for up to 0.5 seconds
1191
- # for a message to become available. Raises an exception if the timeout
1192
- # is hit
1193
- q.pop_waiting(:timeout => 0.5)
1194
- ```
1195
-
1196
- This method only makes sense for collecting Request/Reply ("RPC") replies.
1197
-
1198
-
1199
- ### Bunny::InvalidCommand is now Bunny::CommandInvalid
1200
-
1201
- `Bunny::InvalidCommand` is now `Bunny::CommandInvalid` (follows
1202
- the exception class naming convention based on response status
1203
- name).
1204
-
1205
-
1206
-
1207
- ## Changes between Bunny 0.9.0.pre12 and 0.9.0.pre13
1208
-
1209
- ### Channels Without Consumers Now Tear Down Consumer Pools
1210
-
1211
- Channels without consumers left (when all consumers were cancelled)
1212
- will now tear down their consumer work thread pools, thus making
1213
- `HotBunnies::Queue#subscribe(:block => true)` calls unblock.
1214
-
1215
- This is typically the desired behavior.
1216
-
1217
- ### Consumer and Channel Available In Delivery Handlers
1218
-
1219
- Delivery handlers registered via `Bunny::Queue#subscribe` now will have
1220
- access to the consumer and channel they are associated with via the
1221
- `delivery_info` argument:
1222
-
1223
- ``` ruby
1224
- q.subscribe do |delivery_info, properties, payload|
1225
- delivery_info.consumer # => the consumer this delivery is for
1226
- delivery_info.consumer # => the channel this delivery is on
1227
- end
1228
- ```
1229
-
1230
- This allows using `Bunny::Queue#subscribe` for one-off consumers
1231
- much easier, including when used with the `:block` option.
1232
-
1233
- ### Bunny::Exchange#wait_for_confirms
1234
-
1235
- `Bunny::Exchange#wait_for_confirms` is a convenience method on `Bunny::Exchange` that
1236
- delegates to the method with the same name on exchange's channel.
1237
-
1238
-
1239
- ## Changes between Bunny 0.9.0.pre11 and 0.9.0.pre12
1240
-
1241
- ### Ruby 1.8 Compatibility Regression Fix
1242
-
1243
- `Bunny::Socket` no longer uses Ruby 1.9-specific constants.
1244
-
1245
-
1246
- ### Bunny::Channel#wait_for_confirms Return Value Regression Fix
1247
-
1248
- `Bunny::Channel#wait_for_confirms` returns `true` or `false` again.
1249
-
1250
-
1251
-
1252
- ## Changes between Bunny 0.9.0.pre10 and 0.9.0.pre11
1253
-
1254
- ### Bunny::Session#create_channel Now Accepts Consumer Work Pool Size
1255
-
1256
- `Bunny::Session#create_channel` now accepts consumer work pool size as
1257
- the second argument:
1258
-
1259
- ``` ruby
1260
- # nil means channel id will be allocated by Bunny.
1261
- # 8 is the number of threads in the consumer work pool this channel will use.
1262
- ch = conn.create_channel(nil, 8)
1263
- ```
1264
-
1265
- ### Heartbeat Fix For Long Running Consumers
1266
-
1267
- Long running consumers that don't send any data will no longer
1268
- suffer from connections closed by RabbitMQ because of skipped
1269
- heartbeats.
1270
-
1271
- Activity tracking now takes sent frames into account.
1272
-
1273
-
1274
- ### Time-bound continuations
1275
-
1276
- If a network loop exception causes "main" session thread to never
1277
- receive a response, methods such as `Bunny::Channel#queue` will simply time out
1278
- and raise Timeout::Error now, which can be handled.
1279
-
1280
- It will not start automatic recovery for two reasons:
1281
-
1282
- * It will be started in the network activity loop anyway
1283
- * It may do more damage than good
1284
-
1285
- Kicking off network recovery manually is a matter of calling
1286
- `Bunny::Session#handle_network_failure`.
1287
-
1288
- The main benefit of this implementation is that it will never
1289
- block the main app/session thread forever, and it is really
1290
- efficient on JRuby thanks to a j.u.c. blocking queue.
1291
-
1292
- Fixes #112.
1293
-
1294
-
1295
- ### Logging Support
1296
-
1297
- Every Bunny connection now has a logger. By default, Bunny will use STDOUT
1298
- as logging device. This is configurable using the `:log_file` option:
1299
-
1300
- ``` ruby
1301
- require "bunny"
1302
-
1303
- conn = Bunny.new(:log_level => :warn)
1304
- ```
1305
-
1306
- or the `BUNNY_LOG_LEVEL` environment variable that can take one of the following
1307
- values:
1308
-
1309
- * `debug` (very verbose)
1310
- * `info`
1311
- * `warn`
1312
- * `error`
1313
- * `fatal` (least verbose)
1314
-
1315
- Severity is set to `warn` by default. To disable logging completely, set the level
1316
- to `fatal`.
1317
-
1318
- To redirect logging to a file or any other object that can act as an I/O entity,
1319
- pass it to the `:log_file` option.
1320
-
1321
-
1322
- ## Changes between Bunny 0.9.0.pre9 and 0.9.0.pre10
1323
-
1324
- This release contains a **breaking API change**.
1325
-
1326
- ### Concurrency Improvements On JRuby
1327
-
1328
- On JRuby, Bunny now will use `java.util.concurrent`-backed implementations
1329
- of some of the concurrency primitives. This both improves client stability
1330
- (JDK concurrency primitives has been around for 9 years and have
1331
- well-defined, documented semantics) and opens the door to solving
1332
- some tricky failure handling problems in the future.
1333
-
1334
-
1335
- ### Explicitly Closed Sockets
1336
-
1337
- Bunny now will correctly close the socket previous connection had
1338
- when recovering from network issues.
1339
-
1340
-
1341
- ### Bunny::Exception Now Extends StandardError
1342
-
1343
- `Bunny::Exception` now inherits from `StandardError` and not `Exception`.
1344
-
1345
- Naked rescue like this
1346
-
1347
- ``` ruby
1348
- begin
1349
- # ...
1350
- rescue => e
1351
- # ...
1352
- end
1353
- ```
1354
-
1355
- catches only descendents of `StandardError`. Most people don't
1356
- know this and this is a very counter-intuitive practice, but
1357
- apparently there is code out there that can't be changed that
1358
- depends on this behavior.
1359
-
1360
- This is a **breaking API change**.
1361
-
1362
-
1363
-
1364
- ## Changes between Bunny 0.9.0.pre8 and 0.9.0.pre9
1365
-
1366
- ### Bunny::Session#start Now Returns a Session
1367
-
1368
- `Bunny::Session#start` now returns a session instead of the default channel
1369
- (which wasn't intentional, default channel is a backwards-compatibility implementation
1370
- detail).
1371
-
1372
- `Bunny::Session#start` also no longer leaves dead threads behind if called multiple
1373
- times on the same connection.
1374
-
1375
-
1376
- ### More Reliable Heartbeat Sender
1377
-
1378
- Heartbeat sender no longer slips into an infinite loop if it encounters an exception.
1379
- Instead, it will just stop (and presumably re-started when the network error recovery
1380
- kicks in or the app reconnects manually).
1381
-
1382
-
1383
- ### Network Recovery After Delay
1384
-
1385
- Network reconnection now kicks in after a delay to avoid aggressive
1386
- reconnections in situations when we don't want to endlessly reconnect
1387
- (e.g. when the connection was closed via the Management UI).
1388
-
1389
- The `:network_recovery_interval` option passed to `Bunny::Session#initialize` and `Bunny.new`
1390
- controls the interval. Default is 5 seconds.
1391
-
1392
-
1393
- ### Default Heartbeat Value Is Now Server-Defined
1394
-
1395
- Bunny will now use heartbeat value provided by RabbitMQ by default.
1396
-
1397
-
1398
-
1399
- ## Changes between Bunny 0.9.0.pre7 and 0.9.0.pre8
1400
-
1401
- ### Stability Improvements
1402
-
1403
- Several stability improvements in the network
1404
- layer, connection error handling, and concurrency hazards.
1405
-
1406
-
1407
- ### Automatic Connection Recovery Can Be Disabled
1408
-
1409
- Automatic connection recovery now can be disabled by passing
1410
- the `:automatically_recover => false` option to `Bunny#initialize`).
1411
-
1412
- When the recovery is disabled, network I/O-related exceptions will
1413
- cause an exception to be raised in thee thread the connection was
1414
- started on.
1415
-
1416
-
1417
- ### No Timeout Control For Publishing
1418
-
1419
- `Bunny::Exchange#publish` and `Bunny::Channel#basic_publish` no
1420
- longer perform timeout control (using the timeout module) which
1421
- roughly increases throughput for flood publishing by 350%.
1422
-
1423
- Apps that need delivery guarantees should use publisher confirms.
1424
-
1425
-
1426
-
1427
- ## Changes between Bunny 0.9.0.pre6 and 0.9.0.pre7
1428
-
1429
- ### Bunny::Channel#on_error
1430
-
1431
- `Bunny::Channel#on_error` is a new method that lets you define
1432
- handlers for channel errors that are caused by methods that have no
1433
- responses in the protocol (`basic.ack`, `basic.reject`, and `basic.nack`).
1434
-
1435
- This is rarely necessary but helps make sure no error goes unnoticed.
1436
-
1437
- Example:
1438
-
1439
- ``` ruby
1440
- channel.on_error |ch, channel_close|
1441
- puts channel_close.inspect
1442
- end
1443
- ```
1444
-
1445
- ### Fixed Framing of Larger Messages With Unicode Characters
1446
-
1447
- Larger (over 128K) messages with non-ASCII characters are now always encoded
1448
- correctly with amq-protocol `1.2.0`.
1449
-
1450
-
1451
- ### Efficiency Improvements
1452
-
1453
- Publishing of large messages is now done more efficiently.
1454
-
1455
- Contributed by Greg Brockman.
1456
-
1457
-
1458
- ### API Reference
1459
-
1460
- [Bunny API reference](http://reference.rubybunny.info) is now up online.
1461
-
1462
-
1463
- ### Bunny::Channel#basic_publish Support For :persistent
1464
-
1465
- `Bunny::Channel#basic_publish` now supports both
1466
- `:delivery_mode` and `:persistent` options.
1467
-
1468
- ### Bunny::Channel#nacked_set
1469
-
1470
- `Bunny::Channel#nacked_set` is a counter-part to `Bunny::Channel#unacked_set`
1471
- that contains `basic.nack`-ed (rejected) delivery tags.
1472
-
1473
-
1474
- ### Single-threaded Network Activity Mode
1475
-
1476
- Passing `:threaded => false` to `Bunny.new` now will use the same
1477
- thread for publisher confirmations (may be useful for retry logic
1478
- implementation).
1479
-
1480
- Contributed by Greg Brockman.
1481
-
1482
-
1483
- ## Changes between Bunny 0.9.0.pre5 and 0.9.0.pre6
1484
-
1485
- ### Automatic Network Failure Recovery
1486
-
1487
- Automatic Network Failure Recovery is a new Bunny feature that was earlier
1488
- impemented and vetted out in [amqp gem](http://rubyamqp.info). What it does
1489
- is, when a network activity loop detects an issue, it will try to
1490
- periodically recover [first TCP, then] AMQP 0.9.1 connection, reopen
1491
- all channels, recover all exchanges, queues, bindings and consumers
1492
- on those channels (to be clear: this only includes entities and consumers added via
1493
- Bunny).
1494
-
1495
- Publishers and consumers will continue operating shortly after the network
1496
- connection recovers.
1497
-
1498
- Learn more in the [Error Handling and Recovery](http://rubybunny.info/articles/error_handling.html)
1499
- documentation guide.
1500
-
1501
- ### Confirms Listeners
1502
-
1503
- Bunny now supports listeners (callbacks) on
1504
-
1505
- ``` ruby
1506
- ch.confirm_select do |delivery_tag, multiple, nack|
1507
- # handle confirms (e.g. perform retries) here
1508
- end
1509
- ```
1510
-
1511
- Contributed by Greg Brockman.
1512
-
1513
- ### Publisher Confirms Improvements
1514
-
1515
- Publisher confirms implementation now uses non-strict equality (`<=`) for
1516
- cases when multiple messages are confirmed by RabbitMQ at once.
1517
-
1518
- `Bunny::Channel#unconfirmed_set` is now part of the public API that lets
1519
- developers access unconfirmed delivery tags to perform retries and such.
1520
-
1521
- Contributed by Greg Brockman.
1522
-
1523
- ### Publisher Confirms Concurrency Fix
1524
-
1525
- `Bunny::Channel#wait_for_confirms` will now correctly block the calling
1526
- thread until all pending confirms are received.
1527
-
1528
-
1529
- ## Changes between Bunny 0.9.0.pre4 and 0.9.0.pre5
1530
-
1531
- ### Channel Errors Reset
1532
-
1533
- Channel error information is now properly reset when a channel is (re)opened.
1534
-
1535
- GH issue: #83.
1536
-
1537
- ### Bunny::Consumer#initial Default Change
1538
-
1539
- the default value of `Bunny::Consumer` noack argument changed from false to true
1540
- for consistency.
1541
-
1542
- ### Bunny::Session#prefetch Removed
1543
-
1544
- Global prefetch is not implemented in RabbitMQ, so `Bunny::Session#prefetch`
1545
- is gone from the API.
1546
-
1547
- ### Queue Redeclaration Bug Fix
1548
-
1549
- Fixed a problem when a queue was not declared after being deleted and redeclared
1550
-
1551
- GH issue: #80
1552
-
1553
- ### Channel Cache Invalidation
1554
-
1555
- Channel queue and exchange caches are now properly invalidated when queues and
1556
- exchanges are deleted.
1557
-
1558
-
1559
- ## Changes between Bunny 0.9.0.pre3 and 0.9.0.pre4
1560
-
1561
- ### Heartbeats Support Fixes
1562
-
1563
- Heartbeats are now correctly sent at safe intervals (half of the configured
1564
- interval). In addition, setting `:heartbeat => 0` (or `nil`) will disable
1565
- heartbeats, just like in Bunny 0.8 and [amqp gem](http://rubyamqp.info).
1566
-
1567
- Default `:heartbeat` value is now `600` (seconds), the same as RabbitMQ 3.0
1568
- default.
1569
-
1570
-
1571
- ### Eliminate Race Conditions When Registering Consumers
1572
-
1573
- Fixes a potential race condition between `basic.consume-ok` handler and
1574
- delivery handler when a consumer is registered for a queue that has
1575
- messages in it.
1576
-
1577
- GH issue: #78.
1578
-
1579
- ### Support for Alternative Authentication Mechanisms
1580
-
1581
- Bunny now supports two authentication mechanisms and can be extended
1582
- to support more. The supported methods are `"PLAIN"` (username
1583
- and password) and `"EXTERNAL"` (typically uses TLS, UNIX sockets or
1584
- another mechanism that does not rely on username/challenge pairs).
1585
-
1586
- To use the `"EXTERNAL"` method, pass `:auth_mechanism => "EXTERNAL"` to
1587
- `Bunny.new`:
1588
-
1589
- ``` ruby
1590
- # uses the EXTERNAL authentication mechanism
1591
- conn = Bunny.new(:auth_method => "EXTERNAL")
1592
- conn.start
1593
- ```
1594
-
1595
- ### Bunny::Consumer#cancel
1596
-
1597
- A new high-level API method: `Bunny::Consumer#cancel`, can be used to
1598
- cancel a consumer. `Bunny::Queue#subscribe` will now return consumer
1599
- instances when the `:block` option is passed in as `false`.
1600
-
1601
-
1602
- ### Bunny::Exchange#delete Behavior Change
1603
-
1604
- `Bunny::Exchange#delete` will no longer delete pre-declared exchanges
1605
- that cannot be declared by Bunny (`amq.*` and the default exchange).
1606
-
1607
-
1608
- ### Bunny::DeliveryInfo#redelivered?
1609
-
1610
- `Bunny::DeliveryInfo#redelivered?` is a new method that is an alias
1611
- to `Bunny::DeliveryInfo#redelivered` but follows the Ruby community convention
1612
- about predicate method names.
1613
-
1614
- ### Corrected Bunny::DeliveryInfo#delivery_tag Name
1615
-
1616
- `Bunny::DeliveryInfo#delivery_tag` had a typo which is now fixed.
1617
-
1618
-
1619
- ## Changes between Bunny 0.9.0.pre2 and 0.9.0.pre3
1620
-
1621
- ### Client Capabilities
1622
-
1623
- Bunny now correctly lists RabbitMQ extensions it currently supports in client capabilities:
1624
-
1625
- * `basic.nack`
1626
- * exchange-to-exchange bindings
1627
- * consumer cancellation notifications
1628
- * publisher confirms
1629
-
1630
- ### Publisher Confirms Support
1631
-
1632
- [Lightweight Publisher Confirms](http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/) is a
1633
- RabbitMQ feature that lets publishers keep track of message routing without adding
1634
- noticeable throughput degradation as it is the case with AMQP 0.9.1 transactions.
1635
-
1636
- Bunny `0.9.0.pre3` supports publisher confirms. Publisher confirms are enabled per channel,
1637
- using the `Bunny::Channel#confirm_select` method. `Bunny::Channel#wait_for_confirms` is a method
1638
- that blocks current thread until the client gets confirmations for all unconfirmed published
1639
- messages:
1640
-
1641
- ``` ruby
1642
- ch = connection.create_channel
1643
- ch.confirm_select
1644
-
1645
- ch.using_publisher_confirmations? # => true
1646
-
1647
- q = ch.queue("", :exclusive => true)
1648
- x = ch.default_exchange
1649
-
1650
- 5000.times do
1651
- x.publish("xyzzy", :routing_key => q.name)
1652
- end
1653
-
1654
- ch.next_publish_seq_no.should == 5001
1655
- ch.wait_for_confirms # waits until all 5000 published messages are acknowledged by RabbitMQ
1656
- ```
1657
-
1658
-
1659
- ### Consumers as Objects
1660
-
1661
- It is now possible to register a consumer as an object instead
1662
- of a block. Consumers that are class instances support cancellation
1663
- notifications (e.g. when a queue they're registered with is deleted).
1664
-
1665
- To support this, Bunny introduces two new methods: `Bunny::Channel#basic_consume_with`
1666
- and `Bunny::Queue#subscribe_with`, that operate on consumer objects. Objects are
1667
- supposed to respond to three selectors:
1668
-
1669
- * `:handle_delivery` with 3 arguments
1670
- * `:handle_cancellation` with 1 argument
1671
- * `:consumer_tag=` with 1 argument
1672
-
1673
- An example:
1674
-
1675
- ``` ruby
1676
- class ExampleConsumer < Bunny::Consumer
1677
- def cancelled?
1678
- @cancelled
1679
- end
1680
-
1681
- def handle_cancellation(_)
1682
- @cancelled = true
1683
- end
1684
- end
1685
-
1686
- # "high-level" API
1687
- ch1 = connection.create_channel
1688
- q1 = ch1.queue("", :auto_delete => true)
1689
-
1690
- consumer = ExampleConsumer.new(ch1, q)
1691
- q1.subscribe_with(consumer)
1692
-
1693
- # "low-level" API
1694
- ch2 = connection.create_channel
1695
- q1 = ch2.queue("", :auto_delete => true)
1696
-
1697
- consumer = ExampleConsumer.new(ch2, q)
1698
- ch2.basic_consume_with.(consumer)
1699
- ```
1700
-
1701
- ### RABBITMQ_URL ENV variable support
1702
-
1703
- If `RABBITMQ_URL` environment variable is set, Bunny will assume
1704
- it contains a valid amqp URI string and will use it. This is convenient
1705
- with some PaaS technologies such as Heroku.
1706
-
1707
-
1708
- ## Changes between Bunny 0.9.0.pre1 and 0.9.0.pre2
1709
-
1710
- ### Change Bunny::Queue#pop default for :ack to false
1711
-
1712
- It makes more sense for beginners that way.
1713
-
1714
-
1715
- ### Bunny::Queue#subscribe now support the new :block option
1716
-
1717
- `Bunny::Queue#subscribe` support the new `:block` option
1718
- (a boolean).
1719
-
1720
- It controls whether the current thread will be blocked
1721
- by `Bunny::Queue#subscribe`.
1722
-
1723
-
1724
- ### Bunny::Exchange#publish now supports :key again
1725
-
1726
- `Bunny::Exchange#publish` now supports `:key` as an alias for
1727
- `:routing_key`.
1728
-
1729
-
1730
- ### Bunny::Session#queue et al.
1731
-
1732
- `Bunny::Session#queue`, `Bunny::Session#direct`, `Bunny::Session#fanout`, `Bunny::Session#topic`,
1733
- and `Bunny::Session#headers` were added to simplify migration. They all delegate to their respective
1734
- `Bunny::Channel` methods on the default channel every connection has.
1735
-
1736
-
1737
- ### Bunny::Channel#exchange, Bunny::Session#exchange
1738
-
1739
- `Bunny::Channel#exchange` and `Bunny::Session#exchange` were added to simplify
1740
- migration:
1741
-
1742
- ``` ruby
1743
- b = Bunny.new
1744
- b.start
1745
-
1746
- # uses default connection channel
1747
- x = b.exchange("logs.events", :topic)
1748
- ```
1749
-
1750
- ### Bunny::Queue#subscribe now properly takes 3 arguments
1751
-
1752
- ``` ruby
1753
- q.subscribe(:exclusive => false, :ack => false) do |delivery_info, properties, payload|
1754
- # ...
1755
- end
1756
- ```
1757
-
1758
-
1759
-
1760
- ## Changes between Bunny 0.8.x and 0.9.0.pre1
1761
-
1762
- ### New convenience functions: Bunny::Channel#fanout, Bunny::Channel#topic
1763
-
1764
- `Bunny::Channel#fanout`, `Bunny::Channel#topic`, `Bunny::Channel#direct`, `Bunny::Channel#headers`,
1765
- and`Bunny::Channel#default_exchange` are new convenience methods to instantiate exchanges:
1766
-
1767
- ``` ruby
1768
- conn = Bunny.new
1769
- conn.start
1770
-
1771
- ch = conn.create_channel
1772
- x = ch.fanout("logging.events", :durable => true)
1773
- ```
1774
-
1775
-
1776
- ### Bunny::Queue#pop and consumer handlers (Bunny::Queue#subscribe) signatures have changed
1777
-
1778
- Bunny `< 0.9.x` example:
1779
-
1780
- ``` ruby
1781
- h = queue.pop
1782
-
1783
- puts h[:delivery_info], h[:header], h[:payload]
1784
- ```
1785
-
1786
- Bunny `>= 0.9.x` example:
1787
-
1788
- ``` ruby
1789
- delivery_info, properties, payload = queue.pop
1790
- ```
1791
-
1792
- The improve is both in that Ruby has positional destructuring, e.g.
1793
-
1794
- ``` ruby
1795
- delivery_info, _, content = q.pop
1796
- ```
1797
-
1798
- but not hash destructuring, like, say, Clojure does.
1799
-
1800
- In addition we return nil for content when it should be nil
1801
- (basic.get-empty) and unify these arguments betwee
1802
-
1803
- * Bunny::Queue#pop
1804
-
1805
- * Consumer (Bunny::Queue#subscribe, etc) handlers
1806
-
1807
- * Returned message handlers
1808
-
1809
- The unification moment was the driving factor.
1810
-
1811
-
1812
-
1813
- ### Bunny::Client#write now raises Bunny::ConnectionError
1814
-
1815
- Bunny::Client#write now raises `Bunny::ConnectionError` instead of `Bunny::ServerDownError` when network
1816
- I/O operations fail.
1817
-
1818
-
1819
- ### Bunny::Client.create_channel now uses a bitset-based allocator
1820
-
1821
- Instead of reusing channel instances, `Bunny::Client.create_channel` now opens new channels and
1822
- uses bitset-based allocator to keep track of used channel ids. This avoids situations when
1823
- channels are reused or shared without developer's explicit intent but also work well for
1824
- long running applications that aggressively open and release channels.
1825
-
1826
- This is also how amqp gem and RabbitMQ Java client manage channel ids.
1827
-
1828
-
1829
- ### Bunny::ServerDownError is now Bunny::TCPConnectionFailed
1830
-
1831
- `Bunny::ServerDownError` is now an alias for `Bunny::TCPConnectionFailed`