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