bunny 3.0.0 → 3.2.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.
data/ChangeLog.md ADDED
@@ -0,0 +1,2630 @@
1
+ ## Changes between Bunny 3.1.0 and 3.2.0 (Aug 19, 2026)
2
+
3
+ ### Modernization for Ruby 3.x
4
+
5
+ Contributed by @eglitobias.
6
+
7
+ GitHub issue: [#735](https://github.com/ruby-amqp/bunny/pull/735)
8
+
9
+ ### `amq-protocol` Bump to `2.8.0`
10
+
11
+ This version optimizes deserialization of a few frame types,
12
+ most benefitting applications that primarily consume messages.
13
+
14
+ ### Bug Fixes
15
+
16
+ #### Connection Recovery Survives connection.close During Negotiation and Repeated Failures Mid-Recovery
17
+
18
+ Overlapping (concurrent) connection recovery attempts could leave a client
19
+ permanently disconnected, in particular when target node was put into maintenance mode
20
+ which closes all client connections before the node is restarted.
21
+
22
+ Several changes address this scenario:
23
+
24
+ * Connection recovery now uses a mutex to avoid concurrent attempts
25
+ * The connection status is set to `:open` and the heartbeat sender is started
26
+ only after `connection.open-ok` is actually received
27
+ * A `connection.close` received during negotiation with automatic recovery
28
+ enabled is now raised in the recovery thread and handled by the recovery
29
+ retry logic, instead of being delivered to the session error handler
30
+ * Socket read timeout is now applied early, which means that a disabled
31
+ (by maintenance mode) protocol listener would not cause client connections
32
+ to linger waiting for a socket event that will never arrive
33
+
34
+
35
+ In addition, a failure to redeclare a single entity during topology recovery no
36
+ longer aborts the entire recovery process and will catch transport timeout
37
+ exceptions.
38
+
39
+ #### Reader Loop No Longer Crashes on a Frameset for an Already Closed Channel
40
+
41
+ `Session#handle_frameset` now guards against a missing channel like `Session#handle_frame` already did.
42
+
43
+ GitHub issue: [#741](https://github.com/ruby-amqp/bunny/issues/741)
44
+
45
+ #### `Bunny::Consumer` Identity Preserved on Recovery
46
+
47
+ Consumers registered via `Queue#subscribe_with` or `Channel#basic_consume_with`
48
+ are no longer replaced with a freshly constructed `Bunny::Consumer` during
49
+ automatic connection recovery.
50
+
51
+ The original instance is restored, so callbacks such as `on_cancellation` defined
52
+ before recovery continue to function.
53
+
54
+ Contributed by @jollopre.
55
+
56
+ GitHub issue: [#737](https://github.com/ruby-amqp/bunny/issues/737)
57
+
58
+
59
+ ## Changes between Bunny 3.0.0 and 3.1.0 (Apr 1, 2026)
60
+
61
+ ### `on_error` Callback Runs in a Separate Thread
62
+
63
+ `Channel#on_error` callbacks are now invoked in a separate thread
64
+ when triggered by the reader loop. This allows callbacks to perform
65
+ blocking operations such as `Channel#reopen` without deadlocking.
66
+
67
+ ### Internal Connection Recovery Improvements
68
+
69
+ A detected connection failure now immediately marks all channels
70
+ on the connection as closed.
71
+
72
+ This has no practical consequences for most applications but
73
+ helps make connection recovery tests more robust.
74
+
75
+
76
+ ## Changes between Bunny 2.24.0 and 3.0.0 (March 31, 2026)
77
+
78
+ ### Topology Recovery Improvements
79
+
80
+ Back in 2013-2014, RabbitMQ Java client's connection recovery was heavily
81
+ influenced by what was available in Bunny.
82
+
83
+ In 2025, Bunny starts adopting the features Java client has developed
84
+ over the years, starting with connection-level topology tracking.
85
+
86
+ Now all exchanges, queues, bindings recorded for topology recovery are stored
87
+ and maintained by `Bunny::Session` and not `Bunny::Channel`. This makes
88
+ recovery somewhat simpler and eliminates a class of problems where,
89
+ say, a queue was declared on one channel, deleted on another, and re-created
90
+ by Bunny's connection recovery contrary to the user's intent.
91
+
92
+ The only potentially breaking change here is: the client now intentionally skips
93
+ tracking queue and exchange declarations with `passive: true`.
94
+
95
+ GitHub issues: [#704](https://github.com/ruby-amqp/bunny/issues/704), [#711](https://github.com/ruby-amqp/bunny/issues/711)
96
+
97
+ ### Reduced Connection Recovery Logging
98
+
99
+ On connections that have connection recovery enabled, certain I/O exceptions
100
+ are now logged at debug level to reduce log noise.
101
+
102
+ GitHub issue: [#711](https://github.com/ruby-amqp/bunny/issues/711)
103
+
104
+ ### Topology Recovery Filters
105
+
106
+ ```ruby
107
+ class ExampleTopologyFilter < Bunny::TopologyRecoveryFilter
108
+ def filter_queues(qs)
109
+ qs.filter { |rq| rq.name.start_with?(/^filter-me/) }
110
+ end
111
+
112
+ def filter_exchanges(xs)
113
+ xs.filter { |rx| rx.name.start_with?(/^filter-me/) }
114
+ end
115
+
116
+ def filter_queue_bindings(bs)
117
+ bs.filter { |rb| rb.destination.start_with?(/^filter-me/) }
118
+ end
119
+
120
+ def filter_exchange_bindings(bs)
121
+ bs.filter { |rb| rb.destination.start_with?(/^filter-me/) }
122
+ end
123
+
124
+ def filter_consumers(bs)
125
+ bs.filter { |rc| rc.consumer_tag.start_with?(/filter-me/) }
126
+ end
127
+ end
128
+
129
+ tf = ExampleTopologyFilter.new
130
+ # Will use the above filter to determine what queues, exchanges, bindings,
131
+ # and consumers must be retained (recovered) during topology recovery
132
+ c = Bunny::Session.new(topology_recovery_filter: tf)
133
+ c.start
134
+ ```
135
+
136
+ ### Removed Versioned Delivery Tags
137
+
138
+ Versioned delivery tags introduced about as many problems as they have solved.
139
+
140
+ Originally introduced in 2013 shortly after automatic connection recovery,
141
+ they have been a polarizing feature for years.
142
+
143
+ 3.0 is a good opportunity to remove them.
144
+
145
+ GitHub issue: [#700](https://github.com/ruby-amqp/bunny/issues/700).
146
+
147
+ ### Significant Publisher Performance Improvements
148
+
149
+ Publisher performance improvements (100K messages, with [amq-protocol `2.4.0`](https://github.com/ruby-amqp/amq-protocol/releases/tag/v2.4.0) or later)
150
+ with automatic publisher confirm tracking enabled (documented below):
151
+
152
+ | Approach | Throughput | vs 2.x confirms |
153
+ |----------|------------|-----------------|
154
+ | 2.x `wait_for_confirms` | ~11k msg/s | baseline |
155
+ | 3.x single publish | ~35k msg/s | 320% |
156
+ | 3.x `basic_publish_batch(500)` | ~43k msg/s | 390% |
157
+ | 3.x `basic_publish_batch(1000)` | ~45k msg/s | 410% |
158
+ | 3.x `basic_publish_batch(2000)` | ~44k msg/s | 400% |
159
+ | 3.x `basic_publish_batch(3000)` | ~43k msg/s | 390% |
160
+
161
+ Bunny 3.0's confirm tracking is 3-4x faster than 2.x. Batch size of 1000
162
+ provides optimal throughput. Avoid batches over 3000 (they will perform worse due to
163
+ connection flow control on the RabbitMQ end).
164
+
165
+ To migrate from `2.x`, simply replace `Channel#confirm_select` calls with `Channel#confirm_select(tracking: true)`.
166
+ That's it.
167
+
168
+ In addition, `Bunny::Channel#basic_publish_batch` benefits further from the write hot path optimizations
169
+ that do not benefit `Bunny::Channel#basic_publish` much.
170
+
171
+ ### Publisher Confirm Tracking
172
+
173
+ Bunny now supports [publisher confirm](https://www.rabbitmq.com/docs/publishers#data-safety)
174
+ tracking, inspired by the [.NET client 7.x](https://github.com/rabbitmq/rabbitmq-dotnet-client)
175
+ and [Swift Bunny](https://github.com/michaelklishin/bunny-swift).
176
+
177
+ Use `basic_publish_batch` for optimal throughput (batch sizes of 500-3000 recommended):
178
+
179
+ ```ruby
180
+ ch.confirm_select(tracking: true)
181
+
182
+ messages.each_slice(1000) do |batch|
183
+ ch.basic_publish_batch(batch, "", queue.name)
184
+ end
185
+ ```
186
+
187
+ Single-message publishing is also supported but slower:
188
+
189
+ ```ruby
190
+ ch.confirm_select(tracking: true)
191
+ messages.each { |msg| x.publish(msg, routing_key: q.name) }
192
+ ```
193
+
194
+ When `tracking` is set to `true`, `outstanding_limit` defaults to 1000 (this is an optimal value according to the benchmarks, see below).
195
+ This provides backpressure when too many messages are unconfirmed.
196
+
197
+ If the broker nacks a message, a `Bunny::MessageNacked` exception is raised.
198
+
199
+ **Performance** (100K messages, with [amq-protocol `2.7.0`](https://github.com/ruby-amqp/amq-protocol/releases/tag/v2.7.0)):
200
+
201
+ | Approach | Throughput | vs 2.x confirms |
202
+ |----------|------------|-----------------|
203
+ | 2.x `wait_for_confirms` | ~11k msg/s | baseline |
204
+ | 3.x single publish | ~35k msg/s | 320% |
205
+ | 3.x `basic_publish_batch(500)` | ~43k msg/s | 390% |
206
+ | 3.x `basic_publish_batch(1000)` | ~45k msg/s | 410% |
207
+ | 3.x `basic_publish_batch(2000)` | ~44k msg/s | 400% |
208
+ | 3.x `basic_publish_batch(3000)` | ~43k msg/s | 390% |
209
+
210
+ Bunny 3.0's confirm tracking is 3-4x faster than 2.x. Batch size of 1000
211
+ provides optimal throughput. Avoid batches over 3000 (they will perform worse due to
212
+ connection flow control on the RabbitMQ end).
213
+
214
+ To migrate from `2.x`, simply replace `Channel#confirm_select` calls with `Channel#confirm_select(tracking: true)`.
215
+ With that single line you get automatic backpressure via publisher confirms and three times better throughput.
216
+
217
+ **Important design note**: unlike the .NET client 7.x and Swift Bunny, which both pause the caller per-message using the `async`/`await`
218
+ features in those languages (this is very cheap: just suspends a task), Bunny in Ruby uses a watermark approach
219
+ with a shared condition variable. This avoids per-message mutex contention that has a dramatic negative performance effect.
220
+
221
+ ### Consumer Delivery Performance Optimizations
222
+
223
+ Several optimizations to reduce overhead in the consumer delivery hot path:
224
+
225
+ * `DeliveryInfo`: hash representation is now lazily created only when accessed via
226
+ `to_hash`, `each`, or `[]`; direct method access (e.g., `delivery_tag`, `routing_key`)
227
+ no longer allocates a hash, providing a roughly x2 speedup on microbenchmarks of very simplistic consumers
228
+
229
+ * Consumer lookup caching: channels now cache the last consumer lookup, benefiting
230
+ the common single-consumer-per-channel pattern
231
+
232
+ * Frame header buffer reuse: the transport layer now reuses a buffer when reading
233
+ frame headers, reducing per-frame allocations
234
+
235
+ ### Exchange Type Constants
236
+
237
+ `Bunny::Exchange` now provides constants for all built-in and commonly used
238
+ exchange types: `TYPE_DIRECT`, `TYPE_FANOUT`, `TYPE_TOPIC`, `TYPE_HEADERS`,
239
+ `TYPE_MODULUS_HASH`, `TYPE_LOCAL_RANDOM`, `TYPE_CONSISTENT_HASH`, `TYPE_RANDOM`.
240
+
241
+ ### Tanzu RabbitMQ Delayed Queue Support
242
+
243
+ `Bunny::Queue::Types::DELAYED` and `Channel#delayed_queue` declare a
244
+ Tanzu RabbitMQ delayed queue with optional `:delayed_retry_type`,
245
+ `:delayed_retry_min`, and `:delayed_retry_max` options.
246
+
247
+ ### Tanzu RabbitMQ JMS Queue Support
248
+
249
+ `Bunny::Queue::Types::JMS` and `Channel#jms_queue` declare a
250
+ Tanzu RabbitMQ JMS queue with optional `:selector_fields` and
251
+ `:selector_field_max_bytes` options.
252
+
253
+ ### `Channel#reopen`
254
+
255
+ A new method that reopens a channel after a server-initiated closure
256
+ (e.g. due to a consumer delivery acknowledgement timeout or an unknown delivery tag).
257
+ The channel is reopened on the same connection, reusing its original channel id,
258
+ and its prefetch, confirm, and transactional settings are recovered.
259
+
260
+ ### `Session#recover_channel_topology`
261
+
262
+ Recovers topology (exchanges, queues, bindings, consumers) for a single channel.
263
+ Intended for use after `Channel#reopen`.
264
+
265
+ ### `amq-protocol` Bumped to `2.7.0` (or Later)
266
+
267
+ Bunny now requires `amq-protocol` `2.7.0` or later for the `Channel::Close`
268
+ predicate methods (`#unknown_delivery_tag?`, `#delivery_ack_timeout?`, `#message_too_large?`)
269
+ that Bunny used to reinvent (with regular expression matches on `reply_text`)
270
+
271
+ ### Limit Hostname Resolution Time
272
+
273
+ Bunny now configures its TCP socket to limit the hostname resolution time,
274
+ assuming that the OS kernel supports the underlying socket option.
275
+
276
+ ### Breaking Changes
277
+
278
+ Except for the `VersionedDeliveryTag` removal, all breaking changes in this release are minor and
279
+ do not affect most codebases that use Bunny.
280
+
281
+ * `Bunny::Channel.new` signature has changed: the third positional argument is now `opts = {}` (an option hash) instead of a consumer work pool.
282
+ Use `Bunny::Session#create_channel` or pass the work pool as `opts[:work_pool]`
283
+ * `VersionedDeliveryTag` removed: delivery tags are now raw integers
284
+ * `Consumer#recover_from_network_failure` was removed: topology recovery is now handled by `Bunny::Session` via `TopologyRegistry`
285
+ * `Exchange#recover_from_network_failure` was removed: see above
286
+ * `Queue#recover_from_network_failure` and `Queue#recover_bindings` were removed: see above
287
+
288
+
289
+ ## Changes between Bunny 2.23.0 and 2.24.0 (March 23, 2025)
290
+
291
+ ### An Option that Will Cancel Consumers Before a Channel Closing is Initiated
292
+
293
+ Sometimes it makes more sense to avoid any possible in-flight deliveries
294
+ rather than trying to deal with them in a reasonable way, even though
295
+ all outstanding deliveries that were not confirmed will be requeued after
296
+ a channel closure event.
297
+
298
+ Here is how this setting is supposed to be used:
299
+
300
+ ```ruby
301
+ c = Bunny.new; c.start
302
+ ch = c.create_channel.configure do |new_ch|
303
+ new_ch.prefetch(10)
304
+ new_ch.cancel_consumers_before_closing!
305
+ end
306
+
307
+ q = ch.quorum_queue("a.queue")
308
+ ```
309
+
310
+ This setting is opt-in and disabled by default.
311
+
312
+
313
+ ## Changes between Bunny 2.22.0 and 2.23.0 (July 1, 2024)
314
+
315
+ ### Bunny::Channel#on_error invoked for [delivery acknowledgement timeouts](https://www.rabbitmq.com/docs/consumers#acknowledgement-timeout)
316
+
317
+ Contributed by @dchompd.
318
+
319
+ GitHub issue: [#684](https://github.com/ruby-amqp/bunny/pull/684)
320
+
321
+ ### Heartbeat sender now uses a monotonic clock function
322
+
323
+ Contributed by @blowfishpro.
324
+
325
+ GitHub issue: [#676](https://github.com/ruby-amqp/bunny/issues/676)
326
+
327
+
328
+ ## Changes between Bunny 2.21.0 and 2.22.0 (June 12, 2023)
329
+
330
+ ### New Connection Callback: `:recovery_attempts_exhausted`
331
+
332
+ A new connection callback, `:recovery_attempts_exhausted`, is invoked when
333
+ all allowed recovery attempts have failed.
334
+
335
+ Contributed by @Schmitze333.
336
+
337
+ GitHub issue: [#666](https://github.com/ruby-amqp/bunny/pull/666)
338
+
339
+ ### `Bunny::Channel#default_exchange` Caching
340
+
341
+ `Bunny::Channel#default_exchange` now caches the `Bunny::Exchange` instance
342
+ it returns.
343
+
344
+ GitHub issue: [#661](https://github.com/ruby-amqp/bunny/issues/661)
345
+
346
+
347
+ ## Changes between Bunny 2.20.3 and 2.21.0 (June 8, 2023)
348
+
349
+ ### Fixed a Potential Deadlock During Consumer Work Pool Shutdown
350
+
351
+ Contributed by @parhs.
352
+
353
+ GitHub issue: [#664](https://github.com/ruby-amqp/bunny/pull/664)
354
+
355
+ ### Connection Recovery Reliability Improvements
356
+
357
+ Contributed by @womblep.
358
+
359
+ GitHub issue: [#658](https://github.com/ruby-amqp/bunny/pull/658)
360
+
361
+
362
+ ## Changes between Bunny 2.20.2 and 2.22.3 (January 25, 2023)
363
+
364
+ ### Make sure Bunny can load in environments with older OpenSSL
365
+
366
+ Bunny 2.20.x failed to load in environments that provide an old
367
+ version of OpenSSL without TLS 1.3 support.
368
+
369
+ GitHub issue: [#652](https://github.com/ruby-amqp/bunny/issues/652).
370
+
371
+
372
+ ## Changes between Bunny 2.20.1 and 2.20.2 (January 12, 2023)
373
+
374
+ ### Correctly propagate updated x-arguments when declaring a queue
375
+
376
+ Contributed by @rene-muehlboeck.
377
+
378
+ Github issue: [#650](https://github.com/ruby-amqp/bunny/issues/650).
379
+
380
+ ## Changes between Bunny 2.20.0 and 2.20.1 (December 19, 2022)
381
+
382
+ Starting with this release, Bunny **targets Ruby installations with TLSv1.3 support**.
383
+ This means that some older distributions, e.g. Ubuntu 16.04, 18.04, CentOS 7
384
+ **will no longer be supported**.
385
+
386
+ Those distributions have usually reached their end of general support (there won't be
387
+ maintenance releases besides security patches for paying customers of those distributions),
388
+ so the benefits of TLSv1.3 support outweigh the cons.
389
+
390
+ ### Gracefully Handles a Race Condition Between Server-sent and Client Channel Closure
391
+
392
+ Contributed by @milgner.
393
+
394
+ GitHub issue: [#644](https://github.com/ruby-amqp/bunny/pull/644)
395
+
396
+ ## Changes between Bunny 2.19.x and 2.20.0 (December 15, 2022)
397
+
398
+ ### New `Bunny::Channel` helpers for declaring quorum queues and streams
399
+
400
+ Introduce a few helpers for quorum queues, streams, and durable client-named
401
+ queues in general, similar in spirit to `Bunny::Channel#temporary_queue`
402
+ for temporary queues.
403
+
404
+ #### `Bunny::Channel#quorum_queue`
405
+
406
+ `Bunny::Channel#quorum_queue` accepts a name (server-generated names are not supported)
407
+ and a set of [options arguments](https://www.rabbitmq.com/queues.html#optional-arguments),
408
+ and declares a [quorum queue](https://www.rabbitmq.com/quorum-queues.html).
409
+
410
+ Durability, exclusivity, and auto-delete properties will be ignored: it only makes
411
+ sense for [quorum queues](https://www.rabbitmq.com/quorum-queues.html) to be durable, non-exclusive and non-auto-delete since
412
+ they are [all about data safety](https://www.rabbitmq.com/quorum-queues.html#use-cases).
413
+
414
+ #### `Bunny::Channel#stream`
415
+
416
+ `Bunny::Channel#stream` accepts a name (server-generated names are not supported)
417
+ and a set of [options arguments](https://www.rabbitmq.com/queues.html#optional-arguments),
418
+ and declares a [stream](https://www.rabbitmq.com/streams.html) that Bunny
419
+ can use over AMQP 0-9-1 as if it was a replicated queue (without any [stream-specific operations](https://rabbitmq.com/stream.html)).
420
+
421
+ Durability, exclusivity, and auto-delete properties will be ignored: it only makes
422
+ sense for [streams](https://www.rabbitmq.com/streams.html) to be durable, non-exclusive and non-auto-delete since they are by definition a durable replicated data structure for non-transient
423
+ (or at least not entirely transient) data.
424
+
425
+ #### `Bunny::Channel#durable_queue`
426
+
427
+ `Bunny::Channel#durable_queue` accepts a name (server-generated names are not supported),
428
+ a queue type (one of: `Bunny::Queue::Types::QUORUM`, `Bunny::Queue::Types::CLASSIC`, `Bunny::Queue::Types::STREAM`), and a set of [options arguments](https://www.rabbitmq.com/queues.html#optional-arguments),
429
+ and declares a [quorum queue](https://www.rabbitmq.com/quorum-queues.html).
430
+
431
+ Durability, exclusivity, and auto-delete properties will be ignored by design, just
432
+ like `Bunny::Channel#temporary_queue` overrides them to declare transient queues.
433
+
434
+ #### `Bunny::Queue::Types`
435
+
436
+ `Bunny::Queue::Types` is a module with a few constants that represent currently available
437
+ queue types:
438
+
439
+ * `Bunny::Queue::Types::QUORUM`
440
+ * `Bunny::Queue::Types::CLASSIC`
441
+ * `Bunny::Queue::Types::STREAM`
442
+
443
+ Their names are self-explanatory.
444
+
445
+ ### Test Files Left Out of .gem File
446
+
447
+ Test files (specs) are no longer included into the `.gem` file.
448
+
449
+ Contributed by Alexey @alexeyschepin Schepin.
450
+
451
+ GitHub issue: [#621](https://github.com/ruby-amqp/bunny/pull/621)
452
+
453
+
454
+ ## Changes between Bunny 2.18.x and 2.19.0 (June 25, 2021)
455
+
456
+ ### Correct Handling of Publisher Confirms with Multiple Flag Set
457
+
458
+ Bunny was invoking a publisher confirms callback excessively when
459
+ it encountered confirmations with the multiple flag set, wasting CPU cycles for no good reason and
460
+ potentially resulting in incorrect or confusing publishing
461
+ application behavior.
462
+
463
+ Contributed by
464
+
465
+ * Vladislav @yurusov Yurusov
466
+ * Yuri @kinnalru Samoilenko
467
+
468
+ GitHub issue: [#617](https://github.com/ruby-amqp/bunny/pull/617)
469
+
470
+
471
+ ## Changes between Bunny 2.17.x and 2.18.0 (May 4, 2021)
472
+
473
+ ### Ruby 3.0 Compatibility
474
+
475
+ Bunny has switched to use a `SortedSet` from a standalone library.
476
+ As of Ruby 3.0, it is no longer available in the standard library
477
+ (`set`).
478
+
479
+ ### New Option to Silence TLS-related Warnings
480
+
481
+ A new connection option, `tls_silence_warnings`, silences two warnings:
482
+
483
+ * When TLS is enabled but no client certificate/private key pair is provided
484
+ * When [peer verification](https://www.rabbitmq.com/ssl.html#peer-verification) is disabled
485
+
486
+ An example:
487
+
488
+ ``` ruby
489
+ c = Bunny.new("amqps://bunny_gem:bunny_password@hostname/vhost",
490
+ tls: true,
491
+ tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
492
+ tls_protocol: :TLSv1_2,
493
+ verify_peer: false,
494
+ tls_silence_warnings: true)
495
+ c.start
496
+ ```
497
+
498
+ GitHub issue: [#607](https://github.com/ruby-amqp/bunny/issues/607)
499
+
500
+ ### Leaner Gem
501
+
502
+ Bunny gem no longer includes TLS certificates and other Git repository files that are not library
503
+ or test files.
504
+
505
+ GitHub issue: [#612](https://github.com/ruby-amqp/bunny/issues/612)
506
+
507
+ ## Changes between Bunny 2.16.x and 2.17.0 (Sep 11th, 2020)
508
+
509
+ ### Easier to Specify a Client-Provided Connection Name
510
+
511
+ It is now easier to provide a client-provided (custom) connection
512
+ name that will be displayed in the RabbitMQ management UI and mentioned in
513
+ [server logs](https://www.rabbitmq.com/logging.html).
514
+
515
+ Instead of
516
+
517
+ ``` ruby
518
+ conn = Bunny.new(client_properties: {connection_name: "app ABC #{rand}"})
519
+ conn.start
520
+ ```
521
+
522
+ a new top-level connection option now can be used:
523
+
524
+ ``` ruby
525
+ conn = Bunny.new(connection_name: "app ABC #{rand}")
526
+ conn.start
527
+ ```
528
+
529
+ Contributed by @brerx.
530
+
531
+ GitHub issue: [ruby-amqp/bunny#600](https://github.com/ruby-amqp/bunny/pull/600)
532
+
533
+
534
+ ## Changes between Bunny 2.15.0 and 2.16.0 (Aug 14th, 2020)
535
+
536
+ ### Asynchronous Exception Delegate
537
+
538
+ Bunny now can delegate asynchronous connection (`Bunny::Session`) exceptions to an arbitrary
539
+ delegate object. Use the `:session_error_handler` connection setting to pass it.
540
+ The value defaults to `Thread.current`.
541
+
542
+ Contributed by @bbascarevic.
543
+
544
+ GitHub issue: [ruby-amqp/bunny#597](https://github.com/ruby-amqp/bunny/issues/597)
545
+
546
+
547
+ ## Changes between Bunny 2.14.0 and 2.15.0 (Apr 8th, 2020)
548
+
549
+ ### More Defensive Thread Join Operations
550
+
551
+ Bunny is now more defensive around thread join operations which it performs
552
+ when stopping its consumer work pool.
553
+
554
+ `Thread#join` can cause an unhandled exception to be re-raised at
555
+ a very surprising moment. This behavior can also be affected by 3rd party
556
+ libraries, e.g. those that do connection pooling. While Bunny cannot
557
+ fully avoid every possible surprising failure, it now avoids at least
558
+ one such problematic interaction triggered by a custom [interrupt handler](https://ruby-doc.org/core-2.5.1/Thread.html#method-c-handle_interrupt)
559
+ in a 3rd party library.
560
+
561
+ GitHub issue: [#589](https://github.com/ruby-amqp/bunny/issues/589)
562
+
563
+ Contributed by @fuegas.
564
+
565
+ ### Dependency Updates
566
+
567
+ `amq-protocol` dependency has been bumped to `2.3.1` to support `connection.update-secret`
568
+ protocol extension.
569
+
570
+ ### Gem Installation Fixed on Windows
571
+
572
+ `bin/ci`, a directory with symlinks, is no longer included into the gem.
573
+
574
+ Contributed by Jack Xiaosong Xu.
575
+
576
+ ### Lazy Peer Certificate Chain Information Logging
577
+
578
+ Peer certificate chain information is now logged lazily, which prevents
579
+ an obscure exception originating ASN.1 parser and makes the logging
580
+ code evaluate only when it is really necessary.
581
+
582
+ GitHub issue: [#578](https://github.com/ruby-amqp/bunny/pull/578)
583
+
584
+ Contributed by Garrett Thornburg.
585
+
586
+
587
+ ## Changes between Bunny 2.13.0 and 2.14.0 (Feb 20th, 2019)
588
+
589
+ ### Improved Peer Verification Failure Logging
590
+
591
+ When [peer verification](https://www.rabbitmq.com/ssl.html#peer-verification) fails, the connection will now log
592
+ some relevant peer certificate chain details. If Bunny
593
+ log level is set to `debug`, the same information will be logged
594
+ unconditionally.
595
+
596
+ ### Closing Connections without Waiting for Response
597
+
598
+ `Bunny::Session#close` now accepts a parameter that controls whether
599
+ it waits for a `connection.close-ok` frame. Not waiting is useful
600
+ when it is known for a fact that the node might not respond
601
+ (it might be shutting down, connection is known to be interrupted
602
+ or unrecoverable and so on) or waiting is irrelevant to the caller.
603
+
604
+ ### Successful Connection Recovery Notification
605
+
606
+ `Bunny::Session#after_recovery_completed` (accepts a block)
607
+ and a new connection option, `:recovery_completed` (a callable object)
608
+ can be used to react to successful connection and topology recovery.
609
+
610
+ GitHub issue: [#573](https://github.com/ruby-amqp/bunny/pull/573).
611
+
612
+ Contributed by Ionut Popa.
613
+
614
+ ### effin_utf8 Dependency Dropped
615
+
616
+ This library no longer supports Ruby 1.8 and thus
617
+ doesn't need to depend on the `effin_utf8` gem.
618
+
619
+ Contributed by Luciano Sousa.
620
+
621
+
622
+ ## Changes between Bunny 2.12.0 and 2.13.0 (Dec 25th, 2018)
623
+
624
+ ### More Defensive `Bunny::Channel` Method(s)
625
+
626
+ `Bunny::Channel#queue` will now throw an `ArgumentError` if a `nil`
627
+ is passed for queue name.
628
+
629
+ GitHub issue: [#570](https://github.com/ruby-amqp/bunny/issues/570)
630
+
631
+ ### Correct Logging of Recovery Attempts Left
632
+
633
+ During connection recovery, if `recover_attempts` is not set (is `nil`)
634
+ connection could produce confusing log messages.
635
+
636
+ GitHub issue: [#569](https://github.com/ruby-amqp/bunny/issues/569)
637
+
638
+
639
+ ## Changes between Bunny 2.11.0 and 2.12.0 (Sep 22nd, 2018)
640
+
641
+ ### More Defensive Treatment of `queue.declare-ok` Responses
642
+
643
+ Responses for `queue.declare` are now checked against a memoized
644
+ queue name (but only if the queue is not server-named). This helps
645
+ avoids scenarios with overlapping/concurrent requests due to high
646
+ network latency as demonstrated in [#558](https://github.com/ruby-amqp/bunny/issues/558).
647
+
648
+ "Mismatched" responses will be ignored: Bunny channel API would throw
649
+ an exception for such declarations and there would be no way to "return to"
650
+ even if a matching response arrived and was matched with one of the pending
651
+ requests in a reasonable period of time.
652
+
653
+ As part of this work a new Toxiproxy-based test suite was introduced
654
+ to Bunny.
655
+
656
+ GitHub issue: [#558](https://github.com/ruby-amqp/bunny/issues/558)
657
+
658
+ Reproduction steps contributed by Brian Morton and Scott Bonebraker.
659
+
660
+ ### I/O Exceptions from Heartbeat Sender are Now Silent
661
+
662
+ Heartbeat sender's purpose is to notify the peer, not so much
663
+ to detect local connectivity failures; those will be detected
664
+ by the I/O loop and transport.
665
+
666
+ For single threaded connection users that prefer to roll their own
667
+ recovery strategies getting exceptions from the heartbeat sender
668
+ was counterproductive and painful to deal with.
669
+
670
+ As part of this work a new Toxiproxy-based test suite was introduced
671
+ to Bunny.
672
+
673
+ GitHub issue: [#559](https://github.com/ruby-amqp/bunny/issues/559)
674
+
675
+ Contributed by Scott Bonebraker.
676
+
677
+ ### Correct Connection State on Connections that Experienced Missed Heartbeat
678
+
679
+ Connections that experienced connection closure did not always correctly transition to the closed state.
680
+ `Bunny::ConnectionClosedError` will now be thrown when an operation is attempted on such
681
+ connections.
682
+
683
+ GitHub issue: [#561](https://github.com/ruby-amqp/bunny/issues/561)
684
+
685
+ Contributed by Scott Bonebraker.
686
+
687
+ ### Connection Recovery Will Fail When Max Retry Attempt Limit is Exceeded
688
+
689
+ GitHub issue: [#549](https://github.com/ruby-amqp/bunny/issues/549)
690
+
691
+ Contributed by Arlandis Word.
692
+
693
+ ### Squashed Warnings
694
+
695
+ Many warnings have been eliminated.
696
+
697
+ GitHub issue: [#563](https://github.com/ruby-amqp/bunny/issues/563)
698
+
699
+ Contributed by @dacto.
700
+
701
+
702
+ ### API Reference Corrections
703
+
704
+ GitHub issue: [#557](https://github.com/ruby-amqp/bunny/pull/557)
705
+
706
+ Contributed by Bruno Costa.
707
+
708
+
709
+ ## Changes between Bunny 2.10.0 and 2.11.0 (Jun 21st, 2018)
710
+
711
+ ### More Reliable System-wide Trusted Certificate Directory Detection
712
+
713
+ Bunny no longer tries to compile a list of trusted CA certificates on its own.
714
+ Instead it uses an OpenSSL API method that makes OpenSSL set the path(s),
715
+ which should cover more platforms and be forward- and backward-compatible.
716
+
717
+ GitHub issue: [#555](https://github.com/ruby-amqp/bunny/issues/555).
718
+
719
+ Contributed by Ana María Martínez Gómez.
720
+
721
+
722
+
723
+ ## Changes between Bunny 2.9.0 and 2.10.0 (Jun 5th, 2018)
724
+
725
+ `2.10.0` is a maintenance release that introduces a couple of
726
+ **minor potentially breaking changes**.
727
+
728
+
729
+ ### Disabling Heartbeats Also Disables TCP Socket Read Timeouts
730
+
731
+ Disabling heartbeats will now disable TCP socket read timeouts.
732
+
733
+ They go hand in hand and users who prefer TCP keepalives via
734
+ kernel configuration previously had to also explicitly configure
735
+ a zero read timeout.
736
+
737
+ GitHub issue: [#551](https://github.com/ruby-amqp/bunny/pull/551).
738
+
739
+ Contributed by Carl Hörberg.
740
+
741
+
742
+ ### `verify_peer: false` Has the Expected Effect Again
743
+
744
+ Make sure `verify_peer: false` has the expected effect again.
745
+
746
+ Default value of connection's `:verify_peer` option to `true` only when
747
+ all of `:verify_ssl`, `:verify_peer`, and `:verify` are `nil`.
748
+
749
+ GitHub issue: [#541](https://github.com/ruby-amqp/bunny/issues/541).
750
+
751
+ Contributed by Howard Ding.
752
+
753
+
754
+ ### Maximum Number of Channels Limited to 2K by Default
755
+
756
+ Default maximum number of channels is limited to 2047 to reduce the probability
757
+ of severe channel leaks. See [rabbitmq/rabbitmq-server#1593](https://github.com/rabbitmq/rabbitmq-server/issues/1593) for details.
758
+
759
+ Applications that want to use more channels per connection can still configure a higher value
760
+ using the `channel_max` setting (for both Bunny and RabbitMQ server).
761
+
762
+ GitHub issue: [#553](https://github.com/ruby-amqp/bunny/pull/553).
763
+
764
+
765
+
766
+ ### Squashed Some Warnings
767
+
768
+ GitHub issue: [#552](https://github.com/ruby-amqp/bunny/pull/552).
769
+
770
+ Contributed by @utilum.
771
+
772
+
773
+
774
+ ### Disabling Heartbeats Disables TCP Socket Read Timeouts
775
+
776
+ Disabling heartbeats will also disable TCP socket read timeouts,
777
+ since the two are effectively interconnected. In this case a mechanism
778
+ such as [TCP keepalives](http://www.rabbitmq.com/heartbeats.html#tcp-keepalives) is assumed to be used.
779
+
780
+ See [RabbitMQ heartbeats guide](http://www.rabbitmq.com/heartbeats.html) for a more
781
+ detailed overview of the options.
782
+
783
+ GH issue: [#519](https://github.com/ruby-amqp/bunny/issues/519).
784
+
785
+ Contributed by Carl Hörberg.
786
+
787
+
788
+ ## Changes between Bunny 2.8.0 and 2.9.0 (Jan 8th, 2018)
789
+
790
+ ### Ruby 2.2 Requirement
791
+
792
+ Bunny now requires Ruby 2.2.
793
+
794
+
795
+ ### Connection Recovery Now Retries on Timeouts
796
+
797
+ Connection recovery now will retry on TCP connection timeouts.
798
+
799
+ GitHub issue: [#537](https://github.com/ruby-amqp/bunny/pull/537).
800
+
801
+
802
+ ### More URI Query Parameters
803
+
804
+ Bunny now supports more URI query parameters plus aliases
805
+ that are identical to those of the server.
806
+
807
+ Contributed by Andrew Babichev.
808
+
809
+ GitHub issue: [#534](https://github.com/ruby-amqp/bunny/pull/534)
810
+
811
+
812
+
813
+ ## Changes between Bunny 2.7.0 and 2.8.0 (Dec 18th, 2018)
814
+
815
+ This release has **minor breaking public API changes**.
816
+
817
+ ### `Bunny::Channel#close` on a Closed Channel Now Raises a Sensible Exception
818
+
819
+ `Bunny::Channel#close` on an already closed channel will now raise a sensible exception.
820
+ If the channel was closed due to a channel-level protocol exception, that exception will
821
+ be mentioned.
822
+
823
+ GitHub issue: [#528](https://github.com/ruby-amqp/bunny/issues/528), see [9df7cb](https://github.com/ruby-amqp/bunny/commit/9df7cb04d9ff12b1af62a11e239fd81e5472c872) for
824
+ details.
825
+
826
+ ### JRuby 9K Compatibility
827
+
828
+ A JRuby 9K compatibility issue was corrected by Marian Posăceanu.
829
+ Note that JRuby users are recommended to use [March Hare](http://rubymarchhare.info/), a JRuby-oriented client, instead
830
+ of Bunny.
831
+
832
+ GitHub issue: [#529](https://github.com/ruby-amqp/bunny/pull/529)
833
+
834
+ ### Connection Exceptions are Logged as Warning with Automatic Recovery
835
+
836
+ When automatic recovery is enabled, connection errors are now logged as warnings
837
+ and not errors.
838
+
839
+ Contributed by Merten Falk.
840
+
841
+ GitHub issue: [#531](https://github.com/ruby-amqp/bunny/pull/531)
842
+
843
+ ### Server Heartbeat Value as a String
844
+
845
+ It is now possible to specify a server-defined heartbeat value as a string (`"server"`), not just
846
+ a symbol. This makes it easier to load settings from YAML files.
847
+
848
+ Contributed by Tyrone Wilson.
849
+
850
+ GitHub issue: [#524](https://github.com/ruby-amqp/bunny/pull/524)
851
+
852
+
853
+ ## Changes between Bunny 2.7.0 and 2.7.1 (Sep 25th, 2017)
854
+
855
+ ### Sensible Socket Read Timeouts When RabbitMQ is Configured to Disable Heartbeats
856
+
857
+ Bunny now correctly handles scenarios where server is configured
858
+ to disable heartbeats (which is a terrible idea, don't do it!)
859
+
860
+ GitHub issue: [#519](https://github.com/ruby-amqp/bunny/issues/519).
861
+
862
+ ### Bunny::Channel#basic_get Usability
863
+
864
+ `Bunny::Channel#basic_get` invoked with a non-existent queue now
865
+ throws a channel exception instead of a generic operation timeout.
866
+
867
+ GitHub issue: [#518](https://github.com/ruby-amqp/bunny/issues/518).
868
+
869
+ ### Spec Suite Improvements
870
+
871
+ `BUNNY_CERTIFICATE_DIR` environment variable now can be used
872
+ to override local CA and client certificate/key pair directory.
873
+ The directory is expected to be the result directory generated
874
+ by the basic [tls-gen](http://github.com/michaelklishin/tls-gen) profile.
875
+
876
+ TLSv1.0 is no longer used in tests because it's being disabled by default
877
+ by more and more installations as it has known vulnerabilities
878
+ and is no longer considered to be acceptable by several compliance
879
+ standards (e.g. PCI DSS).
880
+
881
+ ### Improved Synchronisation for channel.close Handlers
882
+
883
+ `channel.close` handler will now acquire a lock . This avoids concurrency
884
+ hazards in some rare scenarios when a channel is closed due a protocol
885
+ exception by the server and concurrently opened by user code
886
+ at the same time.
887
+
888
+ ### More Meaningful Error Messages in Bunny::Session#create_channel
889
+
890
+ Sometimes users attempt to open a channel on a connection that
891
+ isn't connected yet because `Bunny::Session#start` was never invoked.
892
+
893
+ `Bunny::Session#create_channel` will now provide a more sensible exception message
894
+ in those cases.
895
+
896
+
897
+ ## Changes between Bunny 2.6.0 and 2.7.0 (May 11th, 2017)
898
+
899
+ ### amq-protocol Update
900
+
901
+ 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
902
+ a change in [how timestamps are encoded](https://github.com/ruby-amqp/amq-protocol/issues/64).
903
+
904
+
905
+ ### `Bunny::ContinuationQueue#poll` Less Prone to Race Conditions
906
+
907
+ `Bunny::ContinuationQueue#poll` was reworked with feedback from Joseph Wong.
908
+
909
+ GitHub issue: [#462](https://github.com/ruby-amqp/bunny/issues/462)
910
+
911
+
912
+ ### Recovery Attempt Counting Strategy Changed
913
+
914
+ Previous behavior is not unreasonable but is not what many users and
915
+ even RabbitMQ team members come to expect. Therefore it can be
916
+ considered a bug.
917
+
918
+ Previously a reconnection counter was preserved between successful
919
+ recoveries. This made the integration test that uses server-sent
920
+ connection.close possible.
921
+
922
+ With this change, the counter is reset after successful reconnection
923
+ but there's an option to go back to the original behavior. We also do
924
+ a hell of a lot more logging.
925
+
926
+ GitHub issue: [#408](https://github.com/ruby-amqp/bunny/issues/408)
927
+
928
+
929
+ ### Absolute Windows File Paths are No Longer treated as Inline Certs
930
+
931
+ Contributed by Jared Smartt.
932
+
933
+ GitHub issue: [#492](https://github.com/ruby-amqp/bunny/issues/492).
934
+
935
+
936
+ ### Opening a Channel on an Intentionally Closed Connection Immediately Raises an Exception
937
+
938
+ Contributed by Alessandro Verlato.
939
+
940
+ GitHub issue: [#465](https://github.com/ruby-amqp/bunny/issues/465)
941
+
942
+
943
+ ### Bunny::ConsumerWorkPool#shutdown Terminates Early When It's Safe to Do So
944
+
945
+ `Bunny::ConsumerWorkPool#shutdown(true)` waited for consumer shutdown
946
+ even if the pool wasn't active (there were no consumers on its
947
+ channel).
948
+
949
+ GitHub issue: [#438](https://github.com/ruby-amqp/bunny/issues/438).
950
+
951
+
952
+ ### Retry on new Ruby 2.1+ variations of `EAGAIN`, `EWOULDBLOCK`
953
+
954
+ GitHub issue: [#456](https://github.com/ruby-amqp/bunny/issues/456)
955
+
956
+
957
+ ### Do Not Modify Host Arrays
958
+
959
+ Bunny now can work with frozen host arrays.
960
+
961
+ GitHub issue: [#446](https://github.com/ruby-amqp/bunny/issues/446)
962
+
963
+
964
+
965
+ ## Changes between Bunny 2.5.0 and 2.6.0 (October 15th, 2016)
966
+
967
+ ### Graceful Shutdown of Consumers
968
+
969
+ Consumer work pool will now allow for a grace period before stopping
970
+ pool threads so that delivery processing in progress can have a chance to finish.
971
+
972
+ GitHub issue: [#437](https://github.com/ruby-amqp/bunny/pull/437)
973
+
974
+ Contributed by Stefan Sedich.
975
+
976
+ ### `Bunny::Channel#wait_for_confirms` Now Throws When Used on a Closed Channel
977
+
978
+ GitHub issue: [#428](https://github.com/ruby-amqp/bunny/pull/428)
979
+
980
+ Contributed by Dimitar Dimitrov.
981
+
982
+ ### Race Condition Eliminated in `Bunny::Channel#wait_for_confirms`
983
+
984
+ GitHub issue: [#424](https://github.com/ruby-amqp/bunny/issues/424)
985
+
986
+ Contributed by Dimitar Dimitrov.
987
+
988
+ ### More Defensive Consumer Work Pool
989
+
990
+ `Bunny::ConsumerWorkPool#join` and `Bunny::ConsumerWorkPool#pause`
991
+ no longer fails with a `NoMethodError` on nil when executed
992
+ on a work pool that doesn't have active threads (consumers).
993
+
994
+ This change is largely cosmetic and won't affect the majority
995
+ of of projects in any way.
996
+
997
+
998
+ ## Changes between Bunny 2.4.0 and 2.5.0 (July 20th, 2016)
999
+
1000
+ ### Exchange Bindings are Now Correctly Recovered
1001
+
1002
+ GitHub issue: [#410](https://github.com/ruby-amqp/bunny/issues/410)
1003
+
1004
+ Contributed by Andrew Bruce.
1005
+
1006
+
1007
+ ### `Bunny::Channel#wait_for_confirms` Awaits While There're Outstanding Unconfirmed Messages
1008
+
1009
+ GitHub issue: [#424](https://github.com/ruby-amqp/bunny/issues/424)
1010
+
1011
+ Contributed by Dimitar Dimitrov.
1012
+
1013
+
1014
+ ### Queue Recovery Respects the `:no_declare` Option
1015
+
1016
+ Queue recovery now respects the `:no_declare` option.
1017
+
1018
+
1019
+ ### `Bunny::Channel#wait_for_confirms` Throws Early
1020
+
1021
+ `Bunny::Channel#wait_for_confirms` now throws an exception
1022
+ early when invoked on a closed channel.
1023
+
1024
+ GitHub issue: [#428](https://github.com/ruby-amqp/bunny/pull/428).
1025
+
1026
+ Contributed by Dimitar Dimitrov.
1027
+
1028
+
1029
+
1030
+ ## Changes between Bunny 2.3.0 and 2.4.0 (June 11th, 2016)
1031
+
1032
+ **This release includes minor breaking API changes**.
1033
+
1034
+ ### Unconfirmed Delivery Tag Set Reset on Network Recovery
1035
+
1036
+ Channels will now reset their unconfirmed delivery tag set after
1037
+ recovery.
1038
+
1039
+ GitHub issue: [#406](https://github.com/ruby-amqp/bunny/pull/406)
1040
+
1041
+ Contributed by Bill Ruddock.
1042
+
1043
+ ### Support (Quoted) IPv6 Addresses in Address Lists
1044
+
1045
+ GitHub issue: [#383](https://github.com/ruby-amqp/bunny/issues/383).
1046
+
1047
+ Contributed by Jeremy Heiler.
1048
+
1049
+ ### Transport#read_fully Doesn't Try to Recover
1050
+
1051
+ Since transport is replaced by a recovering connection
1052
+ anyway, and this produces confusing errors up the stack.
1053
+
1054
+ GitHub issue: [#359](https://github.com/ruby-amqp/bunny/issues/359)
1055
+
1056
+ Contributed by Donal McBreen.
1057
+
1058
+ ### Client-Provided Session `:properties` Merged with Defaults
1059
+
1060
+ Client-Provided Session `:properties` will now be merged with defaults
1061
+ instead of replacing them. This makes it much more convenient to
1062
+ override a single key.
1063
+
1064
+ ### More Predictable RABBITMQ_URL Handling
1065
+
1066
+ **This is a breaking API change**.
1067
+
1068
+ `RABBITMQ_URL` no longer will be used if any other
1069
+ connection options are provided. This makes it possible
1070
+ to use `RABBITMQ_URL` for some connections and options
1071
+ for others in a single OS process.
1072
+
1073
+ GitHub issue: [#403](https://github.com/ruby-amqp/bunny/pull/403)
1074
+
1075
+ Contributed by Jimmy Petersen.
1076
+
1077
+
1078
+ ## Changes between Bunny 2.2.0 and 2.3.0 (Feb 26th, 2016)
1079
+
1080
+ ### Thread#abort_on_exception Setting for Consumer Work Pool Threads
1081
+
1082
+ `Bunny::Session#create_channel` now supports a 3rd argument that,
1083
+ when set to `true`, makes consumer work pool threads to have
1084
+ `Thread#abort_on_exception` set on them.
1085
+
1086
+ GH issue: [#382](https://github.com/ruby-amqp/bunny/pull/382)
1087
+
1088
+ Contributed by Seamus Abshere.
1089
+
1090
+ ### Explicit Transport Closure on Recovery
1091
+
1092
+ Bunny now will explicitly close previously used transport before starting
1093
+ connection recovery.
1094
+
1095
+ GitHub issue: [#377](https://github.com/ruby-amqp/bunny/pull/377).
1096
+
1097
+ Contributed by bkanhoopla.
1098
+
1099
+ ### No TLS Socket Double-init
1100
+
1101
+ Makes sure that TLS sockets are not double-initialized.
1102
+
1103
+ GH issue: [#345](https://github.com/ruby-amqp/bunny/issues/345).
1104
+
1105
+ Contributed by Carl Hörberg.
1106
+
1107
+ ### Lazily Evaluated Debug Log Strings
1108
+
1109
+ GH issue: [#375](https://github.com/ruby-amqp/bunny/pull/375)
1110
+
1111
+ Contributed by Omer Katz.
1112
+
1113
+
1114
+
1115
+ ## Changes between Bunny 2.1.0 and 2.2.0 (Sep 6th, 2015)
1116
+
1117
+ ### Add :addresses to connect options
1118
+
1119
+ Before this the connection options only allowed multiple hosts, an
1120
+ address is a combination of a host and a port. This makes it possible to
1121
+ specify different hosts with different ports.
1122
+
1123
+ Contributed by Bart van Zon (Tele2).
1124
+
1125
+ ### Recover from connection.close by default
1126
+
1127
+ Bunny will now try to reconnect also when server sent connection.close is
1128
+ received, e.g. when a server is restarting (but also when the connection is
1129
+ force closed by the server). This is in-line with how many other clients behave.
1130
+ The old default was `recover_from_connection_close: false`.
1131
+
1132
+ Contributed by Carl Hörberg (CloudAMQP).
1133
+
1134
+
1135
+ ## Changes between Bunny 2.0.0 and 2.1.0
1136
+
1137
+ Bunny 2.1.0 has an **important breaking change**. It is highly
1138
+ advised that 2.1.0 is not mixed with earlier versions of Bunny
1139
+ in case your applications include **integers in message headers**.
1140
+
1141
+ ### Integer Value Serialisation in Headers
1142
+
1143
+ Integer values in headers are now serialised as signed 64-bit integers. Previously
1144
+ they were serialised as 32-bit unsigned integers, causing both underflows
1145
+ and overflows: incorrect values were observed by consumers.
1146
+
1147
+ It is highly
1148
+ advised that 2.1.0 is not mixed with earlier versions of Bunny
1149
+ in case your applications include integers in message headers.
1150
+
1151
+ If that's not the case, Bunny 2.1 will interoperate with any earlier version
1152
+ starting with 0.9.0 just fine. Popular clients in other languages
1153
+ (e.g. Java and .NET) will interoperate with Bunny 2.1.0 without
1154
+ issues.
1155
+
1156
+
1157
+ ### Explicit Ruby 2.0 Requirement
1158
+
1159
+ Bunny now requires Ruby 2.0 in the gemspec.
1160
+
1161
+ Contributed by Carl Hörberg.
1162
+
1163
+ ### JRuby Fix
1164
+
1165
+ Bunny runs again on JRuby. Note that
1166
+ JRuby users are strongly advised to use March Hare instead.
1167
+
1168
+ Contributed by Teodor Pripoae.
1169
+
1170
+
1171
+
1172
+ ## Changes between Bunny 1.7.0 and 2.0.0
1173
+
1174
+ Bunny `2.0` doesn't have any breaking API changes
1175
+ but drops Ruby 1.8 and 1.9 (both EOL'ed) support,
1176
+ hence the version.
1177
+
1178
+ ### Minimum Required Ruby Version is 2.0
1179
+
1180
+ Bunny `2.0` requires Ruby 2.0 or later.
1181
+
1182
+ ## Non-Blocking Writes
1183
+
1184
+ Bunny now uses non-blocking socket writes, uses a reduced
1185
+ number of writes for message publishing (frames are batched
1186
+ into a single write), and handles TCP back pressure from
1187
+ RabbitMQ better.
1188
+
1189
+ Contributed by Irina Bednova and Michael Klishin.
1190
+
1191
+ ### Reduced Timeout Use
1192
+
1193
+ `Bunny::ContinuationQueue#poll` no longer relies on Ruby's `Timeout` which has
1194
+ numerous issues, including starting a new "interruptor" thread per operation,
1195
+ which is far from efficient.
1196
+
1197
+ Contributed by Joe Eli McIlvain and Carl Hörberg.
1198
+
1199
+ ### Capped Number of Connection Recovery Attempts
1200
+
1201
+ `:recovery_attempts` is a new option that limits the number of
1202
+ connection recovery attempts performed by Bunny. `nil` means
1203
+ "no limit".
1204
+
1205
+ Contributed by Irina Bednova.
1206
+
1207
+ ### Bunny::Channel#basic_ack and Related Methods Improvements
1208
+
1209
+ `Bunny::Channel#basic_ack`, `Bunny::Channel#basic_nack`, and `Bunny::Channel#basic_reject`
1210
+ now adjust delivery tags between connection recoveries, as well as have a default value for
1211
+ the second argument.
1212
+
1213
+ Contributed by Wayne Conrad.
1214
+
1215
+ ### Logger Output Remains Consistent
1216
+
1217
+ Setting the `@logger.progname` attribute changes the output of the logger.
1218
+ This is not expected behaviour when the client provides a custom logger.
1219
+ Behaviour remains unchanged when the internally initialized logger is used.
1220
+
1221
+ Contributed by Justin Carter.
1222
+
1223
+ ### prefetch_count is Limited to 65535
1224
+
1225
+ Since `basic.qos`'s `prefetch_count` field is of type `short` in the protocol,
1226
+ Bunny must enforce its maximum allowed value to `2^16 - 1` to avoid
1227
+ confusing issues due to overflow.
1228
+
1229
+ ### Per-Consumer and Per-Channel Prefetch
1230
+
1231
+ Recent RabbitMQ versions support `basic.qos` `global` flag, controlling whether
1232
+ `prefetch` applies per-consumer or per-channel. Bunny `Channel#prefetch` now
1233
+ allows flag to be set as optional parameter, with the same default behaviour as
1234
+ before (per-consumer).
1235
+
1236
+ Contributed by tiredpixel.
1237
+
1238
+
1239
+ ## Changes between Bunny 1.6.0 and 1.7.0
1240
+
1241
+ ### TLS Peer Verification Enabled by Default
1242
+
1243
+ When using TLS, peer verification is now enabled by default.
1244
+ It is still possible to [disable verification](http://rubybunny.info/articles/tls.html), e.g. for convenient
1245
+ development locally.
1246
+
1247
+ Peer verification is a means of protection against man-in-the-middle attacks
1248
+ and is highly recommended in production settings. However, it can be an inconvenience
1249
+ during local development. We believe it's time to have the default to be
1250
+ more secure.
1251
+
1252
+ Contributed by Michael Klishin (Pivotal) and Andre Foeken (Nedap).
1253
+
1254
+
1255
+ ### Higher Default Connection Timeout
1256
+
1257
+ Default connection timeout has been increased to 25 seconds. The older
1258
+ default of 5 seconds wasn't sufficient in some edge cases with DNS
1259
+ resolution (e.g. when primary DNS server is down).
1260
+
1261
+ The value can be overridden at connection time.
1262
+
1263
+ Contributed by Yury Batenko.
1264
+
1265
+
1266
+ ### Socket Read Timeout No Longer Set to 0 With Disabled Heartbeats
1267
+
1268
+ GH issue: [#267](https://github.com/ruby-amqp/bunny/pull/267).
1269
+
1270
+
1271
+ ### JRuby Writes Fixes
1272
+
1273
+ On JRuby, Bunny reverts back to using plain old `write(2)` for writes. The CRuby implementation
1274
+ on JRuby suffers from I/O incompatibilities. Until JRuby
1275
+
1276
+ Bunny users who run on JRuby are highly recommended to switch to [March Hare](http://rubymarchhare.info),
1277
+ which has nearly identical API and is significantly more efficient.
1278
+
1279
+
1280
+ ### Bunny::Session#with_channel Synchronisation Improvements
1281
+
1282
+ `Bunny::Session#with_channel` is now fully synchronised and won't run into `COMMAND_INVALID` errors
1283
+ when used from multiple threads that share a connection.
1284
+
1285
+
1286
+
1287
+ ## Changes between Bunny 1.5.0 and 1.6.0
1288
+
1289
+ ### TLSv1 by Default
1290
+
1291
+ TLS connections now prefer TLSv1 (or later, if available) due to the recently discovered
1292
+ [POODLE attack](https://www.openssl.org/~bodo/ssl-poodle.pdf) on SSLv3.
1293
+
1294
+ Contributed by Michael Klishin (Pivotal) and Justin Powers (Desk.com).
1295
+
1296
+ GH issues:
1297
+
1298
+ * [#259](https://github.com/ruby-amqp/bunny/pull/259)
1299
+ * [#260](https://github.com/ruby-amqp/bunny/pull/260)
1300
+ * [#261](https://github.com/ruby-amqp/bunny/pull/261)
1301
+
1302
+
1303
+ ### Socket Read and Write Timeout Improvements
1304
+
1305
+ Bunny now sets a read timeout on the sockets it opens, and uses
1306
+ `IO.select` timeouts as the most reliable option available
1307
+ on Ruby 1.9 and later.
1308
+
1309
+ GH issue: [#254](https://github.com/ruby-amqp/bunny/pull/254).
1310
+
1311
+ Contributed by Andre Foeken (Nedap).
1312
+
1313
+ ### Inline TLS Certificates Support
1314
+
1315
+ TLS certificate options now accept inline certificates as well as
1316
+ file paths.
1317
+
1318
+ GH issues: [#255](https://github.com/ruby-amqp/bunny/pull/255), [#256](https://github.com/ruby-amqp/bunny/pull/256).
1319
+
1320
+ Contributed by Will Barrett (Sqwiggle).
1321
+
1322
+
1323
+ ## Changes between Bunny 1.4.0 and 1.5.0
1324
+
1325
+ ### Improved Uncaught Exception Handler
1326
+
1327
+ Uncaught exception handler now provides more information about the exception,
1328
+ including its caller (one more stack trace line).
1329
+
1330
+ Contributed by Carl Hörberg (CloudAMQP).
1331
+
1332
+
1333
+ ### Convenience Method for Temporary (Server-named, Exclusive) Queue Declaration
1334
+
1335
+ `Bunny::Channel#temporary_queue` is a convenience method that declares a new
1336
+ server-named exclusive queue:
1337
+
1338
+ ``` ruby
1339
+ q = ch.temporary_queue
1340
+ ```
1341
+
1342
+ Contributed by Daniel Schierbeck (Zendesk).
1343
+
1344
+ ### Recovery Reliability Improvements
1345
+
1346
+ Automatic connection recovery robustness improvements.
1347
+ Contributed by Andre Foeken (Nedap).
1348
+
1349
+ ### Host Lists
1350
+
1351
+ It is now possible to pass the `:hosts` option to `Bunny.new`/`Bunny::Session#initialize`.
1352
+ When connection to RabbitMQ (including during connection recovery), a random host
1353
+ will be chosen from the list.
1354
+
1355
+ Connection shuffling and robustness improvements.
1356
+
1357
+ Contributed by Andre Foeken (Nedap).
1358
+
1359
+ ### Default Channel Removed
1360
+
1361
+ Breaks compatibility with Bunny 0.8.x.
1362
+
1363
+ `Bunny:Session#default_channel` was removed. Please open channels explicitly now,
1364
+ as all the examples in the docs do.
1365
+
1366
+
1367
+ ## Changes between Bunny 1.3.0 and 1.4.0
1368
+
1369
+ ### Channel#wait_for_confirms Returns Immediately If All Publishes Confirmed
1370
+
1371
+ Contributed by Matt Campbell.
1372
+
1373
+ ### Publisher Confirms is In Sync After Recovery
1374
+
1375
+ When a connection is recovered, the sequence counter resets on the
1376
+ broker, but not the client. To keep things in sync the client must store a confirmation
1377
+ offset after a recovery.
1378
+
1379
+ Contributed by Devin Christensen.
1380
+
1381
+ ### NoMethodError on Thread During Shutdown
1382
+
1383
+ During abnormal termination, `Bunny::Session#close` no longer tries
1384
+ to call the non-existent `terminate_with` method on its origin
1385
+ thread.
1386
+
1387
+
1388
+ ## Changes between Bunny 1.2.0 and 1.3.0
1389
+
1390
+ ### TLS Can Be Explicitly Disabled
1391
+
1392
+ TLS now can be explicitly disabled even when connecting (without TLS)
1393
+ to the default RabbitMQ TLS/amqps port (5671):
1394
+
1395
+ ``` ruby
1396
+ conn = Bunny.new(:port => 5671, :tls => false)
1397
+ ```
1398
+
1399
+ Contributed by Muhan Zou.
1400
+
1401
+
1402
+ ### Single Threaded Connections Raise Shutdown Exceptions
1403
+
1404
+ Single threaded Bunny connections will now raise exceptions
1405
+ that occur during shutdown as is (instead of trying to shut down
1406
+ I/O loop which only threaded ones have).
1407
+
1408
+ Contributed by Carl Hörberg.
1409
+
1410
+
1411
+ ### Synchronization Improvements for Session#close
1412
+
1413
+ `Bunny::Session#close` now better synchronizes state transitions,
1414
+ eliminating a few race condition scenarios with I/O reader thread.
1415
+
1416
+
1417
+ ### Bunny::Exchange.default Fix
1418
+
1419
+ `Bunny::Exchange.default` no longer raises an exception.
1420
+
1421
+ Note that it is a legacy compatibility method. Please use
1422
+ `Bunny::Channel#default_exchange` instead.
1423
+
1424
+ Contributed by Justin Litchfield.
1425
+
1426
+ GH issue [#211](https://github.com/ruby-amqp/bunny/pull/211).
1427
+
1428
+ ### Bunny::Queue#pop_as_hash Removed
1429
+
1430
+ `Bunny::Queue#pop_as_hash`, which was added to ease migration
1431
+ to Bunny 0.9, was removed.
1432
+
1433
+ ### Bunny::Queue#pop Wraps Metadata
1434
+
1435
+ `Bunny::Queue#pop` now wraps `basic.get-ok` and message properties
1436
+ into `Bunny::GetResponse` and `Bunny::MessageProperties`, just like
1437
+ `basic.consume` deliveries.
1438
+
1439
+ GH issue: [#212](https://github.com/ruby-amqp/bunny/issues/212).
1440
+
1441
+ ### Better Synchronization for Publisher Confirms
1442
+
1443
+ Publisher confirms implementation now synchronizes unconfirmed
1444
+ set better.
1445
+
1446
+ Contributed by Nicolas Viennot.
1447
+
1448
+ ### Channel Allocation After Recovery
1449
+
1450
+ Channel id allocator is no longer reset after recovery
1451
+ if there are channels open. Makes it possible to open channels
1452
+ on a recovered connection (in addition to the channels
1453
+ it already had).
1454
+
1455
+
1456
+
1457
+ ## Changes between Bunny 1.1.0 and 1.2.0
1458
+
1459
+ ### :key Supported in Bunny::Channel#queue_bind
1460
+
1461
+ It is now possible to use `:key` (which Bunny versions prior to 0.9 used)
1462
+ as well as `:routing_key` as an argument to `Bunny::Queue#bind`.
1463
+
1464
+ ### System Exceptions Not Rescued by the Library
1465
+
1466
+ Bunny now rescues `StandardError` instead of `Exception` where
1467
+ it automatically does so (e.g. when dispatching deliveries to consumers).
1468
+
1469
+ Contributed by Alex Young.
1470
+
1471
+
1472
+ ### Initial Socket Connection Timeout Again Raises Bunny::TCPConnectionFailed
1473
+
1474
+ Initial socket connection timeout again raises `Bunny::TCPConnectionFailed`
1475
+ on the connection origin thread.
1476
+
1477
+ ### Thread Leaks Plugged
1478
+
1479
+ `Bunny::Session#close` on connections that have experienced a network failure
1480
+ will correctly clean up I/O and heartbeat sender threads.
1481
+
1482
+ Contributed by m-o-e.
1483
+
1484
+ ### Bunny::Concurrent::ContinuationQueue#poll Rounding Fix
1485
+
1486
+ `Bunny::Concurrent::ContinuationQueue#poll` no longer floors the argument
1487
+ to the nearest second.
1488
+
1489
+ Contributed by Brian Abreu.
1490
+
1491
+ ### Routing Key Limit
1492
+
1493
+ Per AMQP 0-9-1 spec, routing keys cannot be longer than 255 characters.
1494
+ `Bunny::Channel#basic_publish` and `Bunny::Exchange#publish` now enforces
1495
+ this limit.
1496
+
1497
+ ### Nagle's Algorithm Disabled Correctly
1498
+
1499
+ Bunny now properly disables [Nagle's algorithm](http://boundary.com/blog/2012/05/02/know-a-delay-nagles-algorithm-and-you/)
1500
+ on the sockets it opens. This likely means
1501
+ significantly lower latency for workloads that involve
1502
+ sending a lot of small messages very frequently.
1503
+
1504
+ [Contributed](https://github.com/ruby-amqp/bunny/pull/187) by Nelson Gauthier (AirBnB).
1505
+
1506
+ ### Internal Exchanges
1507
+
1508
+ Exchanges now can be declared as internal:
1509
+
1510
+ ``` ruby
1511
+ ch = conn.create_channel
1512
+ x = ch.fanout("bunny.tests.exchanges.internal", :internal => true)
1513
+ ```
1514
+
1515
+ Internal exchanges cannot be published to by clients and are solely used
1516
+ for [Exchange-to-Exchange bindings](http://rabbitmq.com/e2e.html) and various
1517
+ plugins but apps may still need to bind them. Now it is possible
1518
+ to do so with Bunny.
1519
+
1520
+ ### Uncaught Consumer Exceptions
1521
+
1522
+ Uncaught consumer exceptions are now handled by uncaught exceptions
1523
+ handler that can be defined per channel:
1524
+
1525
+ ``` ruby
1526
+ ch.on_uncaught_exception do |e, consumer|
1527
+ # ...
1528
+ end
1529
+ ```
1530
+
1531
+
1532
+
1533
+ ## Changes between Bunny 1.1.0.rc1 and 1.1.0
1534
+
1535
+ ### Synchronized Session#create_channel and Session#close_channel
1536
+
1537
+ Full bodies of `Bunny::Session#create_channel` and `Bunny::Session#close_channel`
1538
+ are now synchronized, which makes sure concurrent `channel.open` and subsequent
1539
+ operations (e.g. `exchange.declare`) do not result in connection-level exceptions
1540
+ (incorrect connection state transitions).
1541
+
1542
+ ### Corrected Recovery Log Message
1543
+
1544
+ Bunny will now use actual recovery interval in the log.
1545
+
1546
+ Contributed by Chad Fowler.
1547
+
1548
+
1549
+
1550
+
1551
+ ## Changes between Bunny 1.1.0.pre2 and 1.1.0.rc1
1552
+
1553
+ ### Full Channel State Recovery
1554
+
1555
+ Channel recovery now involves recovery of publisher confirms and
1556
+ transaction modes.
1557
+
1558
+
1559
+ ### TLS Without Peer Verification
1560
+
1561
+ Bunny now successfully performs TLS upgrade when peer verification
1562
+ is disabled.
1563
+
1564
+ Contributed by Jordan Curzon.
1565
+
1566
+ ### Bunny::Session#with_channel Ensures the Channel is Closed
1567
+
1568
+ `Bunny::Session#with_channel` now makes sure the channel is closed
1569
+ even if provided block raises an exception
1570
+
1571
+ Contributed by Carl Hoerberg.
1572
+
1573
+
1574
+
1575
+ ### Channel Number = 0 is Rejected
1576
+
1577
+ `Bunny::Session#create_channel` will now reject channel number 0.
1578
+
1579
+
1580
+ ### Single Threaded Mode Fixes
1581
+
1582
+ Single threaded mode no longer fails with
1583
+
1584
+ ```
1585
+ undefined method `event_loop'
1586
+ ```
1587
+
1588
+
1589
+
1590
+ ## Changes between Bunny 1.1.0.pre1 and 1.1.0.pre2
1591
+
1592
+ ### connection.tune.channel_max No Longer Overflows
1593
+
1594
+ `connection.tune.channel_max` could previously be configured to values
1595
+ greater than 2^16 - 1 (65535). This would result in a silent overflow
1596
+ during serialization. The issue was harmless in practice but is still
1597
+ a bug that can be quite confusing.
1598
+
1599
+ Bunny now caps max number of channels to 65535. This allows it to be
1600
+ forward compatible with future RabbitMQ versions that may allow limiting
1601
+ total # of open channels via server configuration.
1602
+
1603
+ ### amq-protocol Update
1604
+
1605
+ Minimum `amq-protocol` version is now `1.9.0` which includes
1606
+ bug fixes and performance improvements for channel ID allocator.
1607
+
1608
+ ### Thread Leaks Fixes
1609
+
1610
+ Bunny will now correctly release heartbeat sender when allocating
1611
+ a new one (usually happens only when connection recovers from a network
1612
+ failure).
1613
+
1614
+
1615
+ ## Changes between Bunny 1.0.0 and 1.1.0.pre1
1616
+
1617
+ ### Versioned Delivery Tag Fix
1618
+
1619
+ Versioned delivery tag now ensures all the arguments it operates
1620
+ (original delivery tag, atomic fixnum instances, etc) are coerced to `Integer`
1621
+ before comparison.
1622
+
1623
+ GitHub issues: #171.
1624
+
1625
+ ### User-Provided Loggers
1626
+
1627
+ Bunny now can use any logger that provides the same API as Ruby standard library's `Logger`:
1628
+
1629
+ ``` ruby
1630
+ require "logger"
1631
+ require "stringio"
1632
+
1633
+ io = StringIO.new
1634
+ # will log to `io`
1635
+ Bunny.new(:logger => Logger.new(io))
1636
+ ```
1637
+
1638
+ ### Default CA's Paths Are Disabled on JRuby
1639
+
1640
+ Bunny uses OpenSSL provided CA certificate paths. This
1641
+ caused problems on some platforms on JRuby (see [jruby/jruby#155](https://github.com/jruby/jruby/issues/1055)).
1642
+
1643
+ To avoid these issues, Bunny no longer uses default CA certificate paths on JRuby
1644
+ (there are no changes for other Rubies), so it's necessary to provide
1645
+ CA certificate explicitly.
1646
+
1647
+ ### Fixes CPU Burn on JRuby
1648
+
1649
+ Bunny now uses slightly different ways of continuously reading from the socket
1650
+ on CRuby and JRuby, to prevent abnormally high CPU usage on JRuby after a
1651
+ certain period of time (the frequency of `EWOULDBLOCK` being raised spiked
1652
+ sharply).
1653
+
1654
+
1655
+
1656
+ ## Changes between Bunny 1.0.0.rc2 and 1.0.0.rc3
1657
+
1658
+ ### [Authentication Failure Notification](http://www.rabbitmq.com/auth-notification.html) Support
1659
+
1660
+ `Bunny::AuthenticationFailureError` is a new auth failure exception
1661
+ that subclasses `Bunny::PossibleAuthenticationFailureError` for
1662
+ backwards compatibility.
1663
+
1664
+ As such, `Bunny::PossibleAuthenticationFailureError`'s error message
1665
+ has changed.
1666
+
1667
+ This extension is available in RabbitMQ 3.2+.
1668
+
1669
+
1670
+ ### Bunny::Session#exchange_exists?
1671
+
1672
+ `Bunny::Session#exchange_exists?` is a new predicate that makes it
1673
+ easier to check if a exchange exists.
1674
+
1675
+ It uses a one-off channel and `exchange.declare` with `passive` set to true
1676
+ under the hood.
1677
+
1678
+ ### Bunny::Session#queue_exists?
1679
+
1680
+ `Bunny::Session#queue_exists?` is a new predicate that makes it
1681
+ easier to check if a queue exists.
1682
+
1683
+ It uses a one-off channel and `queue.declare` with `passive` set to true
1684
+ under the hood.
1685
+
1686
+
1687
+ ### Inline TLS Certificates and Keys
1688
+
1689
+ It is now possible to provide inline client
1690
+ certificate and private key (as strings) instead
1691
+ of filesystem paths. The options are the same:
1692
+
1693
+ * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
1694
+ * `:tls_cert` which now can be a client certificate (public key) in PEM format
1695
+ * `:tls_key` which now can be a client key (private key) in PEM format
1696
+ * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
1697
+
1698
+ For example:
1699
+
1700
+ ``` ruby
1701
+ conn = Bunny.new(:tls => true,
1702
+ :tls_cert => ENV["TLS_CERTIFICATE"],
1703
+ :tls_key => ENV["TLS_PRIVATE_KEY"],
1704
+ :tls_ca_certificates => ["./examples/tls/cacert.pem"])
1705
+ ```
1706
+
1707
+
1708
+
1709
+ ## Changes between Bunny 1.0.0.rc1 and 1.0.0.rc2
1710
+
1711
+ ### Ruby 1.8.7 Compatibility Fixes
1712
+
1713
+ Ruby 1.8.7 compatibility fixes around timeouts.
1714
+
1715
+
1716
+
1717
+ ## Changes between Bunny 1.0.0.pre6 and 1.0.0.rc1
1718
+
1719
+ ### amq-protocol Update
1720
+
1721
+ Minimum `amq-protocol` version is now `1.8.0` which includes
1722
+ a bug fix for messages exactly 128 Kb in size.
1723
+
1724
+
1725
+ ### Add timeout Bunny::ConsumerWorkPool#join
1726
+
1727
+ `Bunny::ConsumerWorkPool#join` now accepts an optional
1728
+ timeout argument.
1729
+
1730
+
1731
+ ## Changes between Bunny 1.0.0.pre5 and 1.0.0.pre6
1732
+
1733
+ ### Respect RABBITMQ_URL value
1734
+
1735
+ `RABBITMQ_URL` env variable will now have effect even if
1736
+ Bunny.new is invoked without arguments.
1737
+
1738
+
1739
+
1740
+ ## Changes between Bunny 1.0.0.pre4 and 1.0.0.pre5
1741
+
1742
+ ### Ruby 1.8 Compatibility
1743
+
1744
+ Bunny is Ruby 1.8-compatible again and no longer references
1745
+ `RUBY_ENGINE`.
1746
+
1747
+ ### Bunny::Session.parse_uri
1748
+
1749
+ `Bunny::Session.parse_uri` is a new method that parses
1750
+ connection URIs into hashes that `Bunny::Session#initialize`
1751
+ accepts.
1752
+
1753
+ ``` ruby
1754
+ Bunny::Session.parse_uri("amqp://user:pwd@broker.eng.megacorp.local/myapp_qa")
1755
+ ```
1756
+
1757
+ ### Default Paths for TLS/SSL CA's on All OS'es
1758
+
1759
+ Bunny now uses OpenSSL to detect default TLS/SSL CA's paths, extending
1760
+ this feature to OS'es other than Linux.
1761
+
1762
+ Contributed by Jingwen Owen Ou.
1763
+
1764
+
1765
+ ## Changes between Bunny 1.0.0.pre3 and 1.0.0.pre4
1766
+
1767
+ ### Default Paths for TLS/SSL CA's on Linux
1768
+
1769
+ Bunny now will use the following TLS/SSL CA's paths on Linux by default:
1770
+
1771
+ * `/etc/ssl/certs/ca-certificates.crt` on Ubuntu/Debian
1772
+ * `/etc/ssl/certs/ca-bundle.crt` on Amazon Linux
1773
+ * `/etc/ssl/ca-bundle.pem` on OpenSUSE
1774
+ * `/etc/pki/tls/certs/ca-bundle.crt` on Fedora/RHEL
1775
+
1776
+ and will log a warning if no CA files are available via default paths
1777
+ or `:tls_ca_certificates`.
1778
+
1779
+ Contributed by Carl Hörberg.
1780
+
1781
+ ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
1782
+
1783
+ It is now possible to re-register a consumer (and use any other synchronous methods)
1784
+ from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
1785
+ thread pool.
1786
+
1787
+
1788
+ ### Bunny::Session#close Fixed for Single Threaded Connections
1789
+
1790
+ `Bunny::Session#close` with single threaded connections no longer fails
1791
+ with a nil pointer exception.
1792
+
1793
+
1794
+
1795
+ ## Changes between Bunny 1.0.0.pre2 and 1.0.0.pre3
1796
+
1797
+ This release has **breaking API changes**.
1798
+
1799
+ ### Safe[r] basic.ack, basic.nack and basic.reject implementation
1800
+
1801
+ Previously if a channel was recovered (reopened) by automatic connection
1802
+ recovery before a message was acknowledged or rejected, it would cause
1803
+ any operation on the channel that uses delivery tags to fail and
1804
+ cause the channel to be closed.
1805
+
1806
+ To avoid this issue, every channel keeps a counter of how many times
1807
+ it has been reopened and marks delivery tags with them. Using a stale
1808
+ tag to ack or reject a message will produce no method sent to RabbitMQ.
1809
+ Note that unacknowledged messages will be requeued by RabbitMQ when connection
1810
+ goes down anyway.
1811
+
1812
+ This involves an API change: `Bunny::DeliveryMetadata#delivery_tag` is now
1813
+ and instance of a class that responds to `#tag` and `#to_i` and is accepted
1814
+ by `Bunny::Channel#ack` and related methods.
1815
+
1816
+ Integers are still accepted by the same methods.
1817
+
1818
+
1819
+ ## Changes between Bunny 1.0.0.pre1 and 1.0.0.pre2
1820
+
1821
+ ### Exclusivity Violation for Consumers Now Raises a Reasonable Exception
1822
+
1823
+ When a second consumer is registered for the same queue on different channels,
1824
+ a reasonable exception (`Bunny::AccessRefused`) will be raised.
1825
+
1826
+
1827
+ ### Reentrant Mutex Implementation
1828
+
1829
+ Bunny now allows mutex impl to be configurable, uses reentrant Monitor
1830
+ by default.
1831
+
1832
+ Non-reentrant mutexes is a major PITA and may affect code that
1833
+ uses Bunny.
1834
+
1835
+ Avg. publishing throughput with Monitor drops slightly from
1836
+ 5.73 Khz to 5.49 Khz (about 4% decrease), which is reasonable
1837
+ for Bunny.
1838
+
1839
+ Apps that need these 4% can configure what mutex implementation
1840
+ is used on per-connection basis.
1841
+
1842
+ ### Eliminated Race Condition in Bunny::Session#close
1843
+
1844
+ `Bunny::Session#close` had a race condition that caused (non-deterministic)
1845
+ exceptions when connection transport was closed before connection
1846
+ reader loop was guaranteed to have stopped.
1847
+
1848
+ ### connection.close Raises Exceptions on Connection Thread
1849
+
1850
+ Connection-level exceptions (including when a connection is closed via
1851
+ management UI or `rabbitmqctl`) will now be raised on the connection
1852
+ thread so they
1853
+
1854
+ * can be handled by applications
1855
+ * do not start connection recovery, which may be uncalled for
1856
+
1857
+ ### Client TLS Certificates are Optional
1858
+
1859
+ Bunny will no longer require client TLS certificates. Note that CA certificate
1860
+ list is still necessary.
1861
+
1862
+ If RabbitMQ TLS configuration requires peer verification, client certificate
1863
+ and private key are mandatory.
1864
+
1865
+
1866
+ ## Changes between Bunny 0.9.0 and 1.0.0.pre1
1867
+
1868
+ ### Publishing Over Closed Connections
1869
+
1870
+ Publishing a message over a closed connection (during a network outage, before the connection
1871
+ is open) will now correctly result in an exception.
1872
+
1873
+ Contributed by Matt Campbell.
1874
+
1875
+
1876
+ ### Reliability Improvement in Automatic Network Failure Recovery
1877
+
1878
+ Bunny now ensures a new connection transport (socket) is initialized
1879
+ before any recovery is attempted.
1880
+
1881
+
1882
+ ### Reliability Improvement in Bunny::Session#create_channel
1883
+
1884
+ `Bunny::Session#create_channel` now uses two separate mutexes to avoid
1885
+ a (very rare) issue when the previous implementation would try to
1886
+ re-acquire the same mutex and fail (Ruby mutexes are non-reentrant).
1887
+
1888
+
1889
+
1890
+ ## Changes between Bunny 0.9.0.rc1 and 0.9.0.rc2
1891
+
1892
+ ### Channel Now Properly Restarts Consumer Pool
1893
+
1894
+ In a case when all consumers are cancelled, `Bunny::Channel`
1895
+ will shut down its consumer delivery thread pool.
1896
+
1897
+ It will also now mark the pool as not running so that it can be
1898
+ started again successfully if new consumers are registered later.
1899
+
1900
+ GH issue: #133.
1901
+
1902
+
1903
+ ### Bunny::Queue#pop_waiting is Removed
1904
+
1905
+ A little bit of background: on MRI, the method raised `ThreadErrors`
1906
+ reliably. On JRuby, we used a different [internal] queue implementation
1907
+ from JDK so it wasn't an issue.
1908
+
1909
+ `Timeout.timeout` uses `Thread#kill` and `Thread#join`, both of which
1910
+ eventually attempt to acquire a mutex used by Queue#pop, which Bunny
1911
+ currently uses for continuations. The mutex is already has an owner
1912
+ and so a ThreadError is raised.
1913
+
1914
+ This is not a problem on JRuby because there we don't use Ruby's
1915
+ Timeout and Queue and instead rely on a JDK concurrency primitive
1916
+ which provides "poll with a timeout".
1917
+
1918
+ [The issue with `Thread#kill` and `Thread#raise`](http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html)
1919
+ has been first investigated and blogged about by Ruby implementers
1920
+ in 2008.
1921
+
1922
+ Finding a workaround will probably take a bit of time and may involve
1923
+ reimplementing standard library and core classes.
1924
+
1925
+ We don't want this issue to block Bunny 0.9 release. Neither we want
1926
+ to ship a broken feature. So as a result, we will drop
1927
+ Bunny::Queue#pop_waiting since it cannot be reliably implemented in a
1928
+ reasonable amount of time on MRI.
1929
+
1930
+ Per issue #131.
1931
+
1932
+
1933
+ ### More Flexible SSLContext Configuration
1934
+
1935
+ Bunny will now upgrade connection to SSL in `Bunny::Session#start`,
1936
+ so it is possible to fine tune SSLContext and socket settings
1937
+ before that:
1938
+
1939
+ ``` ruby
1940
+ require "bunny"
1941
+
1942
+ conn = Bunny.new(:tls => true,
1943
+ :tls_cert => "examples/tls/client_cert.pem",
1944
+ :tls_key => "examples/tls/client_key.pem",
1945
+ :tls_ca_certificates => ["./examples/tls/cacert.pem"])
1946
+
1947
+ puts conn.transport.socket.inspect
1948
+ puts conn.transport.tls_context.inspect
1949
+ ```
1950
+
1951
+ This also means that `Bunny.new` will now open the socket. Previously
1952
+ it was only done when `Bunny::Session#start` was invoked.
1953
+
1954
+
1955
+ ## Changes between Bunny 0.9.0.pre13 and 0.9.0.rc1
1956
+
1957
+ ### TLS Support
1958
+
1959
+ Bunny 0.9 finally supports TLS. There are 3 new options `Bunny.new` takes:
1960
+
1961
+ * `:tls` which, when set to `true`, will set SSL context up and switch to TLS port (5671)
1962
+ * `:tls_cert` which is a string path to the client certificate (public key) in PEM format
1963
+ * `:tls_key` which is a string path to the client key (private key) in PEM format
1964
+ * `:tls_ca_certificates` which is an array of string paths to CA certificates in PEM format
1965
+
1966
+ An example:
1967
+
1968
+ ``` ruby
1969
+ conn = Bunny.new(:tls => true,
1970
+ :tls_cert => "examples/tls/client_cert.pem",
1971
+ :tls_key => "examples/tls/client_key.pem",
1972
+ :tls_ca_certificates => ["./examples/tls/cacert.pem"])
1973
+ ```
1974
+
1975
+
1976
+ ### Bunny::Queue#pop_waiting
1977
+
1978
+ **This function was removed in v0.9.0.rc2**
1979
+
1980
+ `Bunny::Queue#pop_waiting` is a new function that mimics `Bunny::Queue#pop`
1981
+ but will wait until a message is available. It uses a `:timeout` option and will
1982
+ raise an exception if the timeout is hit:
1983
+
1984
+ ``` ruby
1985
+ # given 1 message in the queue,
1986
+ # works exactly as Bunny::Queue#get
1987
+ q.pop_waiting
1988
+
1989
+ # given no messages in the queue, will wait for up to 0.5 seconds
1990
+ # for a message to become available. Raises an exception if the timeout
1991
+ # is hit
1992
+ q.pop_waiting(:timeout => 0.5)
1993
+ ```
1994
+
1995
+ This method only makes sense for collecting Request/Reply ("RPC") replies.
1996
+
1997
+
1998
+ ### Bunny::InvalidCommand is now Bunny::CommandInvalid
1999
+
2000
+ `Bunny::InvalidCommand` is now `Bunny::CommandInvalid` (follows
2001
+ the exception class naming convention based on response status
2002
+ name).
2003
+
2004
+
2005
+
2006
+ ## Changes between Bunny 0.9.0.pre12 and 0.9.0.pre13
2007
+
2008
+ ### Channels Without Consumers Now Tear Down Consumer Pools
2009
+
2010
+ Channels without consumers left (when all consumers were cancelled)
2011
+ will now tear down their consumer work thread pools, thus making
2012
+ `HotBunnies::Queue#subscribe(:block => true)` calls unblock.
2013
+
2014
+ This is typically the desired behavior.
2015
+
2016
+ ### Consumer and Channel Available In Delivery Handlers
2017
+
2018
+ Delivery handlers registered via `Bunny::Queue#subscribe` now will have
2019
+ access to the consumer and channel they are associated with via the
2020
+ `delivery_info` argument:
2021
+
2022
+ ``` ruby
2023
+ q.subscribe do |delivery_info, properties, payload|
2024
+ delivery_info.consumer # => the consumer this delivery is for
2025
+ delivery_info.channel # => the channel this delivery is on
2026
+ end
2027
+ ```
2028
+
2029
+ This allows using `Bunny::Queue#subscribe` for one-off consumers
2030
+ much easier, including when used with the `:block` option.
2031
+
2032
+ ### Bunny::Exchange#wait_for_confirms
2033
+
2034
+ `Bunny::Exchange#wait_for_confirms` is a convenience method on `Bunny::Exchange` that
2035
+ delegates to the method with the same name on exchange's channel.
2036
+
2037
+
2038
+ ## Changes between Bunny 0.9.0.pre11 and 0.9.0.pre12
2039
+
2040
+ ### Ruby 1.8 Compatibility Regression Fix
2041
+
2042
+ `Bunny::Socket` no longer uses Ruby 1.9-specific constants.
2043
+
2044
+
2045
+ ### Bunny::Channel#wait_for_confirms Return Value Regression Fix
2046
+
2047
+ `Bunny::Channel#wait_for_confirms` returns `true` or `false` again.
2048
+
2049
+
2050
+
2051
+ ## Changes between Bunny 0.9.0.pre10 and 0.9.0.pre11
2052
+
2053
+ ### Bunny::Session#create_channel Now Accepts Consumer Work Pool Size
2054
+
2055
+ `Bunny::Session#create_channel` now accepts consumer work pool size as
2056
+ the second argument:
2057
+
2058
+ ``` ruby
2059
+ # nil means channel id will be allocated by Bunny.
2060
+ # 8 is the number of threads in the consumer work pool this channel will use.
2061
+ ch = conn.create_channel(nil, 8)
2062
+ ```
2063
+
2064
+ ### Heartbeat Fix For Long Running Consumers
2065
+
2066
+ Long running consumers that don't send any data will no longer
2067
+ suffer from connections closed by RabbitMQ because of skipped
2068
+ heartbeats.
2069
+
2070
+ Activity tracking now takes sent frames into account.
2071
+
2072
+
2073
+ ### Time-bound continuations
2074
+
2075
+ If a network loop exception causes "main" session thread to never
2076
+ receive a response, methods such as `Bunny::Channel#queue` will simply time out
2077
+ and raise Timeout::Error now, which can be handled.
2078
+
2079
+ It will not start automatic recovery for two reasons:
2080
+
2081
+ * It will be started in the network activity loop anyway
2082
+ * It may do more damage than good
2083
+
2084
+ Kicking off network recovery manually is a matter of calling
2085
+ `Bunny::Session#handle_network_failure`.
2086
+
2087
+ The main benefit of this implementation is that it will never
2088
+ block the main app/session thread forever, and it is really
2089
+ efficient on JRuby thanks to a j.u.c. blocking queue.
2090
+
2091
+ Fixes #112.
2092
+
2093
+
2094
+ ### Logging Support
2095
+
2096
+ Every Bunny connection now has a logger. By default, Bunny will use STDOUT
2097
+ as logging device. This is configurable using the `:log_file` option:
2098
+
2099
+ ``` ruby
2100
+ require "bunny"
2101
+
2102
+ conn = Bunny.new(:log_level => :warn)
2103
+ ```
2104
+
2105
+ or the `BUNNY_LOG_LEVEL` environment variable that can take one of the following
2106
+ values:
2107
+
2108
+ * `debug` (very verbose)
2109
+ * `info`
2110
+ * `warn`
2111
+ * `error`
2112
+ * `fatal` (least verbose)
2113
+
2114
+ Severity is set to `warn` by default. To disable logging completely, set the level
2115
+ to `fatal`.
2116
+
2117
+ To redirect logging to a file or any other object that can act as an I/O entity,
2118
+ pass it to the `:log_file` option.
2119
+
2120
+
2121
+ ## Changes between Bunny 0.9.0.pre9 and 0.9.0.pre10
2122
+
2123
+ This release contains a **breaking API change**.
2124
+
2125
+ ### Concurrency Improvements On JRuby
2126
+
2127
+ On JRuby, Bunny now will use `java.util.concurrent`-backed implementations
2128
+ of some of the concurrency primitives. This both improves client stability
2129
+ (JDK concurrency primitives has been around for 9 years and have
2130
+ well-defined, documented semantics) and opens the door to solving
2131
+ some tricky failure handling problems in the future.
2132
+
2133
+
2134
+ ### Explicitly Closed Sockets
2135
+
2136
+ Bunny now will correctly close the socket previous connection had
2137
+ when recovering from network issues.
2138
+
2139
+
2140
+ ### Bunny::Exception Now Extends StandardError
2141
+
2142
+ `Bunny::Exception` now inherits from `StandardError` and not `Exception`.
2143
+
2144
+ Naked rescue like this
2145
+
2146
+ ``` ruby
2147
+ begin
2148
+ # ...
2149
+ rescue => e
2150
+ # ...
2151
+ end
2152
+ ```
2153
+
2154
+ catches only descendents of `StandardError`. Most people don't
2155
+ know this and this is a very counter-intuitive practice, but
2156
+ apparently there is code out there that can't be changed that
2157
+ depends on this behavior.
2158
+
2159
+ This is a **breaking API change**.
2160
+
2161
+
2162
+
2163
+ ## Changes between Bunny 0.9.0.pre8 and 0.9.0.pre9
2164
+
2165
+ ### Bunny::Session#start Now Returns a Session
2166
+
2167
+ `Bunny::Session#start` now returns a session instead of the default channel
2168
+ (which wasn't intentional, default channel is a backwards-compatibility implementation
2169
+ detail).
2170
+
2171
+ `Bunny::Session#start` also no longer leaves dead threads behind if called multiple
2172
+ times on the same connection.
2173
+
2174
+
2175
+ ### More Reliable Heartbeat Sender
2176
+
2177
+ Heartbeat sender no longer slips into an infinite loop if it encounters an exception.
2178
+ Instead, it will just stop (and presumably re-started when the network error recovery
2179
+ kicks in or the app reconnects manually).
2180
+
2181
+
2182
+ ### Network Recovery After Delay
2183
+
2184
+ Network reconnection now kicks in after a delay to avoid aggressive
2185
+ reconnections in situations when we don't want to endlessly reconnect
2186
+ (e.g. when the connection was closed via the Management UI).
2187
+
2188
+ The `:network_recovery_interval` option passed to `Bunny::Session#initialize` and `Bunny.new`
2189
+ controls the interval. Default is 5 seconds.
2190
+
2191
+
2192
+ ### Default Heartbeat Value Is Now Server-Defined
2193
+
2194
+ Bunny will now use heartbeat value provided by RabbitMQ by default.
2195
+
2196
+
2197
+
2198
+ ## Changes between Bunny 0.9.0.pre7 and 0.9.0.pre8
2199
+
2200
+ ### Stability Improvements
2201
+
2202
+ Several stability improvements in the network
2203
+ layer, connection error handling, and concurrency hazards.
2204
+
2205
+
2206
+ ### Automatic Connection Recovery Can Be Disabled
2207
+
2208
+ Automatic connection recovery now can be disabled by passing
2209
+ the `:automatically_recover => false` option to `Bunny#initialize`).
2210
+
2211
+ When the recovery is disabled, network I/O-related exceptions will
2212
+ cause an exception to be raised in thee thread the connection was
2213
+ started on.
2214
+
2215
+
2216
+ ### No Timeout Control For Publishing
2217
+
2218
+ `Bunny::Exchange#publish` and `Bunny::Channel#basic_publish` no
2219
+ longer perform timeout control (using the timeout module) which
2220
+ roughly increases throughput for flood publishing by 350%.
2221
+
2222
+ Apps that need delivery guarantees should use publisher confirms.
2223
+
2224
+
2225
+
2226
+ ## Changes between Bunny 0.9.0.pre6 and 0.9.0.pre7
2227
+
2228
+ ### Bunny::Channel#on_error
2229
+
2230
+ `Bunny::Channel#on_error` is a new method that lets you define
2231
+ handlers for channel errors that are caused by methods that have no
2232
+ responses in the protocol (`basic.ack`, `basic.reject`, and `basic.nack`).
2233
+
2234
+ This is rarely necessary but helps make sure no error goes unnoticed.
2235
+
2236
+ Example:
2237
+
2238
+ ``` ruby
2239
+ channel.on_error do |ch, channel_close|
2240
+ puts channel_close.inspect
2241
+ end
2242
+ ```
2243
+
2244
+ ### Fixed Framing of Larger Messages With Unicode Characters
2245
+
2246
+ Larger (over 128K) messages with non-ASCII characters are now always encoded
2247
+ correctly with amq-protocol `1.2.0`.
2248
+
2249
+
2250
+ ### Efficiency Improvements
2251
+
2252
+ Publishing of large messages is now done more efficiently.
2253
+
2254
+ Contributed by Greg Brockman.
2255
+
2256
+
2257
+ ### API Reference
2258
+
2259
+ [Bunny API reference](http://reference.rubybunny.info) is now up online.
2260
+
2261
+
2262
+ ### Bunny::Channel#basic_publish Support For :persistent
2263
+
2264
+ `Bunny::Channel#basic_publish` now supports both
2265
+ `:delivery_mode` and `:persistent` options.
2266
+
2267
+ ### Bunny::Channel#nacked_set
2268
+
2269
+ `Bunny::Channel#nacked_set` is a counter-part to `Bunny::Channel#unacked_set`
2270
+ that contains `basic.nack`-ed (rejected) delivery tags.
2271
+
2272
+
2273
+ ### Single-threaded Network Activity Mode
2274
+
2275
+ Passing `:threaded => false` to `Bunny.new` now will use the same
2276
+ thread for publisher confirmations (may be useful for retry logic
2277
+ implementation).
2278
+
2279
+ Contributed by Greg Brockman.
2280
+
2281
+
2282
+ ## Changes between Bunny 0.9.0.pre5 and 0.9.0.pre6
2283
+
2284
+ ### Automatic Network Failure Recovery
2285
+
2286
+ Automatic Network Failure Recovery is a new Bunny feature that was earlier
2287
+ implemented and vetted out in [amqp gem](http://rubyamqp.info). What it does
2288
+ is, when a network activity loop detects an issue, it will try to
2289
+ periodically recover [first TCP, then] AMQP 0.9.1 connection, reopen
2290
+ all channels, recover all exchanges, queues, bindings and consumers
2291
+ on those channels (to be clear: this only includes entities and consumers added via
2292
+ Bunny).
2293
+
2294
+ Publishers and consumers will continue operating shortly after the network
2295
+ connection recovers.
2296
+
2297
+ Learn more in the [Error Handling and Recovery](http://rubybunny.info/articles/error_handling.html)
2298
+ documentation guide.
2299
+
2300
+ ### Confirms Listeners
2301
+
2302
+ Bunny now supports listeners (callbacks) on
2303
+
2304
+ ``` ruby
2305
+ ch.confirm_select do |delivery_tag, multiple, nack|
2306
+ # handle confirms (e.g. perform retries) here
2307
+ end
2308
+ ```
2309
+
2310
+ Contributed by Greg Brockman.
2311
+
2312
+ ### Publisher Confirms Improvements
2313
+
2314
+ Publisher confirms implementation now uses non-strict equality (`<=`) for
2315
+ cases when multiple messages are confirmed by RabbitMQ at once.
2316
+
2317
+ `Bunny::Channel#unconfirmed_set` is now part of the public API that lets
2318
+ developers access unconfirmed delivery tags to perform retries and such.
2319
+
2320
+ Contributed by Greg Brockman.
2321
+
2322
+ ### Publisher Confirms Concurrency Fix
2323
+
2324
+ `Bunny::Channel#wait_for_confirms` will now correctly block the calling
2325
+ thread until all pending confirms are received.
2326
+
2327
+
2328
+ ## Changes between Bunny 0.9.0.pre4 and 0.9.0.pre5
2329
+
2330
+ ### Channel Errors Reset
2331
+
2332
+ Channel error information is now properly reset when a channel is (re)opened.
2333
+
2334
+ GH issue: #83.
2335
+
2336
+ ### Bunny::Consumer#initial Default Change
2337
+
2338
+ the default value of `Bunny::Consumer` noack argument changed from false to true
2339
+ for consistency.
2340
+
2341
+ ### Bunny::Session#prefetch Removed
2342
+
2343
+ Global prefetch is not implemented in RabbitMQ, so `Bunny::Session#prefetch`
2344
+ is gone from the API.
2345
+
2346
+ ### Queue Redeclaration Bug Fix
2347
+
2348
+ Fixed a problem when a queue was not declared after being deleted and redeclared
2349
+
2350
+ GH issue: #80
2351
+
2352
+ ### Channel Cache Invalidation
2353
+
2354
+ Channel queue and exchange caches are now properly invalidated when queues and
2355
+ exchanges are deleted.
2356
+
2357
+
2358
+ ## Changes between Bunny 0.9.0.pre3 and 0.9.0.pre4
2359
+
2360
+ ### Heartbeats Support Fixes
2361
+
2362
+ Heartbeats are now correctly sent at safe intervals (half of the configured
2363
+ interval). In addition, setting `:heartbeat => 0` (or `nil`) will disable
2364
+ heartbeats, just like in Bunny 0.8 and [amqp gem](http://rubyamqp.info).
2365
+
2366
+ Default `:heartbeat` value is now `600` (seconds), the same as RabbitMQ 3.0
2367
+ default.
2368
+
2369
+
2370
+ ### Eliminate Race Conditions When Registering Consumers
2371
+
2372
+ Fixes a potential race condition between `basic.consume-ok` handler and
2373
+ delivery handler when a consumer is registered for a queue that has
2374
+ messages in it.
2375
+
2376
+ GH issue: #78.
2377
+
2378
+ ### Support for Alternative Authentication Mechanisms
2379
+
2380
+ Bunny now supports two authentication mechanisms and can be extended
2381
+ to support more. The supported methods are `"PLAIN"` (username
2382
+ and password) and `"EXTERNAL"` (typically uses TLS, UNIX sockets or
2383
+ another mechanism that does not rely on username/challenge pairs).
2384
+
2385
+ To use the `"EXTERNAL"` method, pass `:auth_mechanism => "EXTERNAL"` to
2386
+ `Bunny.new`:
2387
+
2388
+ ``` ruby
2389
+ # uses the EXTERNAL authentication mechanism
2390
+ conn = Bunny.new(:auth_mechanism => "EXTERNAL")
2391
+ conn.start
2392
+ ```
2393
+
2394
+ ### Bunny::Consumer#cancel
2395
+
2396
+ A new high-level API method: `Bunny::Consumer#cancel`, can be used to
2397
+ cancel a consumer. `Bunny::Queue#subscribe` will now return consumer
2398
+ instances when the `:block` option is passed in as `false`.
2399
+
2400
+
2401
+ ### Bunny::Exchange#delete Behavior Change
2402
+
2403
+ `Bunny::Exchange#delete` will no longer delete pre-declared exchanges
2404
+ that cannot be declared by Bunny (`amq.*` and the default exchange).
2405
+
2406
+
2407
+ ### Bunny::DeliveryInfo#redelivered?
2408
+
2409
+ `Bunny::DeliveryInfo#redelivered?` is a new method that is an alias
2410
+ to `Bunny::DeliveryInfo#redelivered` but follows the Ruby community convention
2411
+ about predicate method names.
2412
+
2413
+ ### Corrected Bunny::DeliveryInfo#delivery_tag Name
2414
+
2415
+ `Bunny::DeliveryInfo#delivery_tag` had a typo which is now fixed.
2416
+
2417
+
2418
+ ## Changes between Bunny 0.9.0.pre2 and 0.9.0.pre3
2419
+
2420
+ ### Client Capabilities
2421
+
2422
+ Bunny now correctly lists RabbitMQ extensions it currently supports in client capabilities:
2423
+
2424
+ * `basic.nack`
2425
+ * exchange-to-exchange bindings
2426
+ * consumer cancellation notifications
2427
+ * publisher confirms
2428
+
2429
+ ### Publisher Confirms Support
2430
+
2431
+ [Lightweight Publisher Confirms](http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/) is a
2432
+ RabbitMQ feature that lets publishers keep track of message routing without adding
2433
+ noticeable throughput degradation as it is the case with AMQP 0.9.1 transactions.
2434
+
2435
+ Bunny `0.9.0.pre3` supports publisher confirms. Publisher confirms are enabled per channel,
2436
+ using the `Bunny::Channel#confirm_select` method. `Bunny::Channel#wait_for_confirms` is a method
2437
+ that blocks current thread until the client gets confirmations for all unconfirmed published
2438
+ messages:
2439
+
2440
+ ``` ruby
2441
+ ch = connection.create_channel
2442
+ ch.confirm_select
2443
+
2444
+ ch.using_publisher_confirmations? # => true
2445
+
2446
+ q = ch.queue("", :exclusive => true)
2447
+ x = ch.default_exchange
2448
+
2449
+ 5000.times do
2450
+ x.publish("xyzzy", :routing_key => q.name)
2451
+ end
2452
+
2453
+ ch.next_publish_seq_no.should == 5001
2454
+ ch.wait_for_confirms # waits until all 5000 published messages are acknowledged by RabbitMQ
2455
+ ```
2456
+
2457
+
2458
+ ### Consumers as Objects
2459
+
2460
+ It is now possible to register a consumer as an object instead
2461
+ of a block. Consumers that are class instances support cancellation
2462
+ notifications (e.g. when a queue they're registered with is deleted).
2463
+
2464
+ To support this, Bunny introduces two new methods: `Bunny::Channel#basic_consume_with`
2465
+ and `Bunny::Queue#subscribe_with`, that operate on consumer objects. Objects are
2466
+ supposed to respond to three selectors:
2467
+
2468
+ * `:handle_delivery` with 3 arguments
2469
+ * `:handle_cancellation` with 1 argument
2470
+ * `:consumer_tag=` with 1 argument
2471
+
2472
+ An example:
2473
+
2474
+ ``` ruby
2475
+ class ExampleConsumer < Bunny::Consumer
2476
+ def cancelled?
2477
+ @cancelled
2478
+ end
2479
+
2480
+ def handle_cancellation(_)
2481
+ @cancelled = true
2482
+ end
2483
+ end
2484
+
2485
+ # "high-level" API
2486
+ ch1 = connection.create_channel
2487
+ q1 = ch1.queue("", :auto_delete => true)
2488
+
2489
+ consumer = ExampleConsumer.new(ch1, q)
2490
+ q1.subscribe_with(consumer)
2491
+
2492
+ # "low-level" API
2493
+ ch2 = connection.create_channel
2494
+ q1 = ch2.queue("", :auto_delete => true)
2495
+
2496
+ consumer = ExampleConsumer.new(ch2, q)
2497
+ ch2.basic_consume_with(consumer)
2498
+ ```
2499
+
2500
+ ### RABBITMQ_URL ENV variable support
2501
+
2502
+ If `RABBITMQ_URL` environment variable is set, Bunny will assume
2503
+ it contains a valid amqp URI string and will use it. This is convenient
2504
+ with some PaaS technologies such as Heroku.
2505
+
2506
+
2507
+ ## Changes between Bunny 0.9.0.pre1 and 0.9.0.pre2
2508
+
2509
+ ### Change Bunny::Queue#pop default for :ack to false
2510
+
2511
+ It makes more sense for beginners that way.
2512
+
2513
+
2514
+ ### Bunny::Queue#subscribe now support the new :block option
2515
+
2516
+ `Bunny::Queue#subscribe` support the new `:block` option
2517
+ (a boolean).
2518
+
2519
+ It controls whether the current thread will be blocked
2520
+ by `Bunny::Queue#subscribe`.
2521
+
2522
+
2523
+ ### Bunny::Exchange#publish now supports :key again
2524
+
2525
+ `Bunny::Exchange#publish` now supports `:key` as an alias for
2526
+ `:routing_key`.
2527
+
2528
+
2529
+ ### Bunny::Session#queue et al.
2530
+
2531
+ `Bunny::Session#queue`, `Bunny::Session#direct`, `Bunny::Session#fanout`, `Bunny::Session#topic`,
2532
+ and `Bunny::Session#headers` were added to simplify migration. They all delegate to their respective
2533
+ `Bunny::Channel` methods on the default channel every connection has.
2534
+
2535
+
2536
+ ### Bunny::Channel#exchange, Bunny::Session#exchange
2537
+
2538
+ `Bunny::Channel#exchange` and `Bunny::Session#exchange` were added to simplify
2539
+ migration:
2540
+
2541
+ ``` ruby
2542
+ b = Bunny.new
2543
+ b.start
2544
+
2545
+ # uses default connection channel
2546
+ x = b.exchange("logs.events", :topic)
2547
+ ```
2548
+
2549
+ ### Bunny::Queue#subscribe now properly takes 3 arguments
2550
+
2551
+ ``` ruby
2552
+ q.subscribe(:exclusive => false, :ack => false) do |delivery_info, properties, payload|
2553
+ # ...
2554
+ end
2555
+ ```
2556
+
2557
+
2558
+
2559
+ ## Changes between Bunny 0.8.x and 0.9.0.pre1
2560
+
2561
+ ### New convenience functions: Bunny::Channel#fanout, Bunny::Channel#topic
2562
+
2563
+ `Bunny::Channel#fanout`, `Bunny::Channel#topic`, `Bunny::Channel#direct`, `Bunny::Channel#headers`,
2564
+ and`Bunny::Channel#default_exchange` are new convenience methods to instantiate exchanges:
2565
+
2566
+ ``` ruby
2567
+ conn = Bunny.new
2568
+ conn.start
2569
+
2570
+ ch = conn.create_channel
2571
+ x = ch.fanout("logging.events", :durable => true)
2572
+ ```
2573
+
2574
+
2575
+ ### Bunny::Queue#pop and consumer handlers (Bunny::Queue#subscribe) signatures have changed
2576
+
2577
+ Bunny `< 0.9.x` example:
2578
+
2579
+ ``` ruby
2580
+ h = queue.pop
2581
+
2582
+ puts h[:delivery_info], h[:header], h[:payload]
2583
+ ```
2584
+
2585
+ Bunny `>= 0.9.x` example:
2586
+
2587
+ ``` ruby
2588
+ delivery_info, properties, payload = queue.pop
2589
+ ```
2590
+
2591
+ The improve is both in that Ruby has positional destructuring, e.g.
2592
+
2593
+ ``` ruby
2594
+ delivery_info, _, content = q.pop
2595
+ ```
2596
+
2597
+ but not hash destructuring, like, say, Clojure does.
2598
+
2599
+ In addition we return nil for content when it should be nil
2600
+ (basic.get-empty) and unify these arguments between
2601
+
2602
+ * Bunny::Queue#pop
2603
+
2604
+ * Consumer (Bunny::Queue#subscribe, etc) handlers
2605
+
2606
+ * Returned message handlers
2607
+
2608
+ The unification moment was the driving factor.
2609
+
2610
+
2611
+
2612
+ ### Bunny::Client#write now raises Bunny::ConnectionError
2613
+
2614
+ Bunny::Client#write now raises `Bunny::ConnectionError` instead of `Bunny::ServerDownError` when network
2615
+ I/O operations fail.
2616
+
2617
+
2618
+ ### Bunny::Client.create_channel now uses a bitset-based allocator
2619
+
2620
+ Instead of reusing channel instances, `Bunny::Client.create_channel` now opens new channels and
2621
+ uses bitset-based allocator to keep track of used channel ids. This avoids situations when
2622
+ channels are reused or shared without developer's explicit intent but also work well for
2623
+ long running applications that aggressively open and release channels.
2624
+
2625
+ This is also how amqp gem and RabbitMQ Java client manage channel ids.
2626
+
2627
+
2628
+ ### Bunny::ServerDownError is now Bunny::TCPConnectionFailed
2629
+
2630
+ `Bunny::ServerDownError` is now an alias for `Bunny::TCPConnectionFailed`