bunny 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/ChangeLog.md +23 -2
- data/Gemfile +3 -3
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/bunny/channel.rb +1 -1
- data/lib/bunny/channel_id_allocator.rb +3 -3
- data/lib/bunny/concurrent/continuation_queue.rb +9 -5
- data/lib/bunny/exceptions.rb +6 -0
- data/lib/bunny/session.rb +69 -11
- data/lib/bunny/transport.rb +1 -1
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_ack_spec.rb +46 -46
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +13 -13
- data/spec/higher_level_api/integration/basic_consume_spec.rb +40 -40
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +5 -5
- data/spec/higher_level_api/integration/basic_get_spec.rb +5 -5
- data/spec/higher_level_api/integration/basic_nack_spec.rb +13 -13
- data/spec/higher_level_api/integration/basic_publish_spec.rb +7 -7
- data/spec/higher_level_api/integration/basic_qos_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_reject_spec.rb +23 -23
- data/spec/higher_level_api/integration/basic_return_spec.rb +3 -3
- data/spec/higher_level_api/integration/channel_close_spec.rb +1 -1
- data/spec/higher_level_api/integration/channel_open_spec.rb +1 -1
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +93 -55
- data/spec/higher_level_api/integration/connection_spec.rb +46 -46
- data/spec/higher_level_api/integration/connection_stop_spec.rb +9 -8
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +14 -14
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +8 -8
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +4 -4
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +10 -10
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +3 -3
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +5 -5
- data/spec/higher_level_api/integration/heartbeat_spec.rb +4 -4
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +10 -10
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +22 -22
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +8 -8
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +10 -10
- data/spec/higher_level_api/integration/queue_bind_spec.rb +10 -10
- data/spec/higher_level_api/integration/queue_declare_spec.rb +14 -11
- data/spec/higher_level_api/integration/queue_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_purge_spec.rb +3 -3
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +4 -4
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +7 -7
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +6 -6
- data/spec/higher_level_api/integration/tls_connection_spec.rb +40 -40
- data/spec/higher_level_api/integration/tx_commit_spec.rb +1 -1
- data/spec/higher_level_api/integration/tx_rollback_spec.rb +1 -1
- data/spec/higher_level_api/integration/with_channel_spec.rb +1 -1
- data/spec/issues/issue100_spec.rb +7 -7
- data/spec/issues/issue141_spec.rb +3 -3
- data/spec/issues/issue224_spec.rb +3 -3
- data/spec/issues/issue465_spec.rb +32 -0
- data/spec/issues/issue78_spec.rb +11 -10
- data/spec/issues/issue83_spec.rb +1 -1
- data/spec/issues/issue97_spec.rb +20 -20
- data/spec/stress/channel_close_stress_spec.rb +3 -3
- data/spec/stress/channel_open_stress_spec.rb +3 -3
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +2 -1
- data/spec/stress/concurrent_consumers_stress_spec.rb +6 -6
- data/spec/stress/concurrent_publishers_stress_spec.rb +2 -1
- data/spec/stress/connection_open_close_spec.rb +3 -3
- data/spec/stress/long_running_consumer_spec.rb +7 -5
- data/spec/unit/concurrent/condition_spec.rb +5 -5
- metadata +4 -6
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 805ab484c94b0c54cafc8d9a895b86b2e204ccbc
|
4
|
+
data.tar.gz: 3982bbb9af0f8c6b4352535804c2fb00f01b8b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd8285ba649b6868d7298f9695b45909753b8a477709e938d4a844365ad87a78644902ffc93105599bbccf56878e5dab4432bdd9ccca2b315ef44855fbe6f06a
|
7
|
+
data.tar.gz: 828eb8792fccbbc8b624ba0a1b6abea3d44523089676479c6e5371c5505ef33ec32f4c3621db3fb93f5f81dfaf3043c87429c841544d4343eba6ad534e6e269f
|
data/.travis.yml
CHANGED
@@ -2,10 +2,11 @@ language: ruby
|
|
2
2
|
bundler_args: --without development
|
3
3
|
cache: bundler
|
4
4
|
before_script: "./bin/ci/before_build"
|
5
|
-
script: "bundle exec
|
5
|
+
script: "bundle exec rake integration_without_recovery"
|
6
6
|
rvm:
|
7
|
-
- "2.
|
8
|
-
- "2.
|
7
|
+
- "2.4.0"
|
8
|
+
- "2.3.3"
|
9
|
+
- "2.2"
|
9
10
|
notifications:
|
10
11
|
email: michael@rabbitmq.com
|
11
12
|
services:
|
@@ -13,3 +14,6 @@ services:
|
|
13
14
|
branches:
|
14
15
|
only:
|
15
16
|
- master
|
17
|
+
- 2.6.x-stable
|
18
|
+
env:
|
19
|
+
- CI=true
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
|
-
## Changes between Bunny 2.6.
|
1
|
+
## Changes between Bunny 2.6.3 and 2.6.4 (unreleased)
|
2
2
|
|
3
|
-
|
3
|
+
### Recovery Attempt Counting Strategy Changed
|
4
|
+
|
5
|
+
Previous behehavior is not unreasonable but is not what many users and
|
6
|
+
even RabbitMQ team members come to expect. Therefore it can be
|
7
|
+
considered a bug.
|
8
|
+
|
9
|
+
Previously a reconnection counter was preserved between successful
|
10
|
+
recoveries. This made the integration test that uses server-sent
|
11
|
+
connection.close possible.
|
12
|
+
|
13
|
+
With this change, the counter is reset after successful reconnection
|
14
|
+
but there's an option to go back to the original behavior. We also do
|
15
|
+
a hell of a lot more logging.
|
16
|
+
|
17
|
+
GitHub issue: [#408](https://github.com/ruby-amqp/bunny/issues/408)
|
18
|
+
|
19
|
+
|
20
|
+
## Changes between Bunny 2.6.2 and 2.6.3 (January 19th, 2016)
|
21
|
+
|
22
|
+
### Retry on new Ruby 2.1+ variations of `EAGAIN`, `EWOULDBLOCK`
|
23
|
+
|
24
|
+
GitHub issue: [#456](https://github.com/ruby-amqp/bunny/issues/456)
|
4
25
|
|
5
26
|
|
6
27
|
## Changes between Bunny 2.6.1 and 2.6.2 (December 17th, 2016)
|
data/Gemfile
CHANGED
@@ -32,8 +32,8 @@ group :development do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
group :test do
|
35
|
-
gem "rspec", "~> 3.
|
36
|
-
gem "rabbitmq_http_api_client", "~> 1.
|
35
|
+
gem "rspec", "~> 3.5.0"
|
36
|
+
gem "rabbitmq_http_api_client", "~> 1.8.0"
|
37
37
|
end
|
38
38
|
|
39
39
|
gemspec
|
@@ -50,4 +50,4 @@ def custom_gem(name, options = Hash.new)
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
custom_gem "amq-protocol", :
|
53
|
+
custom_gem "amq-protocol", git: "https://github.com/ruby-amqp/amq-protocol", branch: "master"
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009 –
|
1
|
+
Copyright (c) 2009 – 2017 Chris Duncan, Jakub Stastny aka botanicus,
|
2
2
|
Michael S. Klishin, Eric Lindvall, Stefan Kaes and contributors.
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Specific examples:
|
|
48
48
|
|
49
49
|
Modern Bunny versions support
|
50
50
|
|
51
|
-
* CRuby 2.0 through 2.
|
51
|
+
* CRuby 2.0 through 2.4
|
52
52
|
|
53
53
|
Bunny works sufficiently well on JRuby but there are known
|
54
54
|
JRuby bugs in versions prior to JRuby 9000 that cause high CPU burn. JRuby users should
|
@@ -88,7 +88,7 @@ gem install bunny
|
|
88
88
|
To use Bunny in a project managed with Bundler:
|
89
89
|
|
90
90
|
``` ruby
|
91
|
-
gem "bunny", ">= 2.
|
91
|
+
gem "bunny", ">= 2.6.3"
|
92
92
|
```
|
93
93
|
|
94
94
|
|
data/lib/bunny/channel.rb
CHANGED
@@ -1975,7 +1975,7 @@ module Bunny
|
|
1975
1975
|
def guarding_against_stale_delivery_tags(tag, &block)
|
1976
1976
|
case tag
|
1977
1977
|
# if a fixnum was passed, execute unconditionally. MK.
|
1978
|
-
when
|
1978
|
+
when Integer then
|
1979
1979
|
block.call
|
1980
1980
|
# versioned delivery tags should be checked to avoid
|
1981
1981
|
# sending out stale (invalid) tags after channel was reopened
|
@@ -25,7 +25,7 @@ module Bunny
|
|
25
25
|
|
26
26
|
# Returns next available channel id. This method is thread safe.
|
27
27
|
#
|
28
|
-
# @return [
|
28
|
+
# @return [Integer]
|
29
29
|
# @api public
|
30
30
|
# @see ChannelManager#release_channel_id
|
31
31
|
# @see ChannelManager#reset_channel_id_allocator
|
@@ -37,7 +37,7 @@ module Bunny
|
|
37
37
|
|
38
38
|
# Releases previously allocated channel id. This method is thread safe.
|
39
39
|
#
|
40
|
-
# @param [
|
40
|
+
# @param [Integer] i Channel id to release
|
41
41
|
# @api public
|
42
42
|
# @see ChannelManager#next_channel_id
|
43
43
|
# @see ChannelManager#reset_channel_id_allocator
|
@@ -51,7 +51,7 @@ module Bunny
|
|
51
51
|
# Returns true if given channel id has been previously allocated and not yet released.
|
52
52
|
# This method is thread safe.
|
53
53
|
#
|
54
|
-
# @param [
|
54
|
+
# @param [Integer] i Channel id to check
|
55
55
|
# @return [Boolean] true if given channel id has been previously allocated and not yet released
|
56
56
|
# @api public
|
57
57
|
# @see ChannelManager#next_channel_id
|
@@ -28,13 +28,17 @@ module Bunny
|
|
28
28
|
timeout = timeout_in_ms ? timeout_in_ms / 1000.0 : nil
|
29
29
|
|
30
30
|
@lock.synchronize do
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
timeout_strikes_at = Time.now.utc + (timeout || 0)
|
32
|
+
while @q.empty?
|
33
|
+
wait = if timeout
|
34
|
+
timeout_strikes_at - Time.now.utc
|
35
|
+
else
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
@cond.wait(@lock, wait)
|
39
|
+
raise ::Timeout::Error if wait && Time.now.utc >= timeout_strikes_at
|
34
40
|
end
|
35
41
|
item = @q.shift
|
36
|
-
@cond.signal
|
37
|
-
|
38
42
|
item
|
39
43
|
end
|
40
44
|
end
|
data/lib/bunny/exceptions.rb
CHANGED
data/lib/bunny/session.rb
CHANGED
@@ -117,8 +117,9 @@ module Bunny
|
|
117
117
|
# @option connection_string_or_opts [IO, String] :logfile DEPRECATED: use :log_file instead. The file or path to use when creating a logger. Defaults to STDOUT.
|
118
118
|
# @option connection_string_or_opts [Integer] :log_level The log level to use when creating a logger. Defaults to LOGGER::WARN
|
119
119
|
# @option connection_string_or_opts [Boolean] :automatically_recover (true) Should automatically recover from network failures?
|
120
|
-
# @option connection_string_or_opts [Integer] :recovery_attempts (nil) Max number of recovery attempts, nil means forever
|
121
|
-
# @option connection_string_or_opts [
|
120
|
+
# @option connection_string_or_opts [Integer] :recovery_attempts (nil) Max number of recovery attempts, nil means forever
|
121
|
+
# @option connection_string_or_opts [Integer] :reset_recovery_attempts_after_reconnection (true) Should recovery attempt counter be reset after successful reconnection? When set to false, the attempt counter will last through the entire lifetime of the connection object.
|
122
|
+
# @option connection_string_or_opts [Boolean] :recover_from_connection_close (true) Should this connection recover after receiving a server-sent connection.close (e.g. connection was force closed)?
|
122
123
|
#
|
123
124
|
# @option optz [String] :auth_mechanism ("PLAIN") Authentication mechanism, PLAIN or EXTERNAL
|
124
125
|
# @option optz [String] :locale ("PLAIN") Locale RabbitMQ should use
|
@@ -164,7 +165,13 @@ module Bunny
|
|
164
165
|
else
|
165
166
|
opts[:automatically_recover] || opts[:automatic_recovery]
|
166
167
|
end
|
167
|
-
@
|
168
|
+
@max_recovery_attempts = opts[:recovery_attempts]
|
169
|
+
@recovery_attempts = @max_recovery_attempts
|
170
|
+
# When this is set, connection attempts won't be reset after
|
171
|
+
# successful reconnection. Some find this behavior more sensible
|
172
|
+
# than the per-failure attempt counter. MK.
|
173
|
+
@reset_recovery_attempt_counter_after_reconnection = opts.fetch(:reset_recovery_attempts_after_reconnection, true)
|
174
|
+
|
168
175
|
@network_recovery_interval = opts.fetch(:network_recovery_interval, DEFAULT_NETWORK_RECOVERY_INTERVAL)
|
169
176
|
@recover_from_connection_close = opts.fetch(:recover_from_connection_close, true)
|
170
177
|
# in ms
|
@@ -318,6 +325,7 @@ module Bunny
|
|
318
325
|
@status_mutex.synchronize { @status = :not_connected }
|
319
326
|
raise TCPConnectionFailedForAllHosts
|
320
327
|
end
|
328
|
+
@status_mutex.synchronize { @manually_closed = false }
|
321
329
|
|
322
330
|
self
|
323
331
|
end
|
@@ -336,6 +344,7 @@ module Bunny
|
|
336
344
|
# @return [Bunny::Channel] Newly opened channel
|
337
345
|
def create_channel(n = nil, consumer_pool_size = 1, consumer_pool_abort_on_exception = false, consumer_pool_shutdown_timeout = 60)
|
338
346
|
raise ArgumentError, "channel number 0 is reserved in the protocol and cannot be used" if 0 == n
|
347
|
+
raise ConnectionAlreadyClosed if manually_closed?
|
339
348
|
|
340
349
|
@channel_mutex.synchronize do
|
341
350
|
if n && (ch = @channels[n])
|
@@ -362,7 +371,10 @@ module Bunny
|
|
362
371
|
|
363
372
|
clean_up_on_shutdown
|
364
373
|
end
|
365
|
-
@status_mutex.synchronize
|
374
|
+
@status_mutex.synchronize do
|
375
|
+
@status = :closed
|
376
|
+
@manually_closed = true
|
377
|
+
end
|
366
378
|
end
|
367
379
|
alias stop close
|
368
380
|
|
@@ -397,6 +409,11 @@ module Bunny
|
|
397
409
|
@status_mutex.synchronize { @status == :closed }
|
398
410
|
end
|
399
411
|
|
412
|
+
# @return [Boolean] true if this AMQP 0.9.1 connection has been programmatically closed
|
413
|
+
def manually_closed?
|
414
|
+
@status_mutex.synchronize { @manually_closed == true }
|
415
|
+
end
|
416
|
+
|
400
417
|
# @return [Boolean] true if this AMQP 0.9.1 connection is open
|
401
418
|
def open?
|
402
419
|
@status_mutex.synchronize do
|
@@ -640,7 +657,7 @@ module Bunny
|
|
640
657
|
begin
|
641
658
|
@recovering_from_network_failure = true
|
642
659
|
if recoverable_network_failure?(exception)
|
643
|
-
|
660
|
+
announce_network_failure_recovery
|
644
661
|
@channel_mutex.synchronize do
|
645
662
|
@channels.each do |n, ch|
|
646
663
|
ch.maybe_kill_consumer_work_pool!
|
@@ -651,7 +668,7 @@ module Bunny
|
|
651
668
|
|
652
669
|
recover_from_network_failure
|
653
670
|
else
|
654
|
-
|
671
|
+
@logger.error "Exception #{exception.message} is considered unrecoverable..."
|
655
672
|
end
|
656
673
|
ensure
|
657
674
|
@recovering_from_network_failure = false
|
@@ -661,7 +678,8 @@ module Bunny
|
|
661
678
|
|
662
679
|
# @private
|
663
680
|
def recoverable_network_failure?(exception)
|
664
|
-
#
|
681
|
+
# No reasonably smart strategy was suggested in a few years.
|
682
|
+
# So just recover unconditionally. MK.
|
665
683
|
true
|
666
684
|
end
|
667
685
|
|
@@ -670,10 +688,19 @@ module Bunny
|
|
670
688
|
@recovering_from_network_failure
|
671
689
|
end
|
672
690
|
|
691
|
+
# @private
|
692
|
+
def announce_network_failure_recovery
|
693
|
+
if recovery_attempts_limited?
|
694
|
+
@logger.warn "Will recover from a network failure (#{@recovery_attempts} out of #{@max_recovery_attempts} left)..."
|
695
|
+
else
|
696
|
+
@logger.warn "Will recover from a network failure (no retry limit)..."
|
697
|
+
end
|
698
|
+
end
|
699
|
+
|
673
700
|
# @private
|
674
701
|
def recover_from_network_failure
|
675
702
|
sleep @network_recovery_interval
|
676
|
-
@logger.debug "
|
703
|
+
@logger.debug "Will attempt connection recovery..."
|
677
704
|
|
678
705
|
self.initialize_transport
|
679
706
|
|
@@ -681,7 +708,16 @@ module Bunny
|
|
681
708
|
self.start
|
682
709
|
|
683
710
|
if open?
|
711
|
+
|
684
712
|
@recovering_from_network_failure = false
|
713
|
+
@logger.debug "Connection is now open"
|
714
|
+
if @reset_recovery_attempt_counter_after_reconnection
|
715
|
+
@logger.debug "Resetting recovery attempt counter after successful reconnection"
|
716
|
+
reset_recovery_attempt_counter!
|
717
|
+
else
|
718
|
+
@logger.debug "Not resetting recovery attempt counter after successful reconnection, as configured"
|
719
|
+
end
|
720
|
+
reset_recovery_attempt_counter!
|
685
721
|
|
686
722
|
recover_channels
|
687
723
|
end
|
@@ -692,14 +728,36 @@ module Bunny
|
|
692
728
|
@logger.warn "TCP connection failed, reconnecting in #{@network_recovery_interval} seconds"
|
693
729
|
sleep @network_recovery_interval
|
694
730
|
if should_retry_recovery?
|
695
|
-
|
696
|
-
|
731
|
+
decrement_recovery_attemp_counter!
|
732
|
+
if recoverable_network_failure?(e)
|
733
|
+
announce_network_failure_recovery
|
734
|
+
retry
|
735
|
+
end
|
736
|
+
else
|
737
|
+
@logger.error "Ran out of recovery attempts (limit set to #{@max_recovery_attempts})"
|
697
738
|
end
|
698
739
|
end
|
699
740
|
|
741
|
+
# @private
|
742
|
+
def recovery_attempts_limited?
|
743
|
+
!!@max_recovery_attempts
|
744
|
+
end
|
745
|
+
|
700
746
|
# @private
|
701
747
|
def should_retry_recovery?
|
702
|
-
|
748
|
+
!recovery_attempts_limited? || @recovery_attempts > 1
|
749
|
+
end
|
750
|
+
|
751
|
+
# @private
|
752
|
+
def decrement_recovery_attemp_counter!
|
753
|
+
@recovery_attempts -= 1 if @recovery_attempts
|
754
|
+
@logger.debug "#{@recovery_attempts} recovery attempts left"
|
755
|
+
@recovery_attempts
|
756
|
+
end
|
757
|
+
|
758
|
+
# @private
|
759
|
+
def reset_recovery_attempt_counter!
|
760
|
+
@recovery_attempts = @max_recovery_attempts
|
703
761
|
end
|
704
762
|
|
705
763
|
# @private
|
data/lib/bunny/transport.rb
CHANGED
@@ -419,7 +419,7 @@ certificate, connection upgrade will fail!
|
|
419
419
|
if !@verify_peer
|
420
420
|
@logger.warn <<-MSG
|
421
421
|
Using TLS but peer hostname verification is disabled. This is convenient for local development
|
422
|
-
but prone man-in-the-middle attacks. Please set :
|
422
|
+
but prone to man-in-the-middle attacks. Please set verify_peer: true in production!
|
423
423
|
MSG
|
424
424
|
end
|
425
425
|
|
data/lib/bunny/version.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Channel, "#ack" do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -14,19 +14,19 @@ describe Bunny::Channel, "#ack" do
|
|
14
14
|
context "with a valid (known) delivery tag" do
|
15
15
|
it "acknowledges a message" do
|
16
16
|
ch = connection.create_channel
|
17
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
17
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
18
18
|
x = ch.default_exchange
|
19
19
|
|
20
|
-
x.publish("bunneth", :
|
20
|
+
x.publish("bunneth", routing_key: q.name)
|
21
21
|
sleep 0.5
|
22
22
|
expect(q.message_count).to eq 1
|
23
|
-
delivery_details, properties, content = q.pop(:
|
23
|
+
delivery_details, properties, content = q.pop(manual_ack: true)
|
24
24
|
|
25
25
|
ch.ack(delivery_details.delivery_tag, true)
|
26
26
|
ch.close
|
27
27
|
|
28
28
|
ch = connection.create_channel
|
29
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
29
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
30
30
|
expect(q.message_count).to eq 0
|
31
31
|
ch.close
|
32
32
|
end
|
@@ -35,21 +35,21 @@ describe Bunny::Channel, "#ack" do
|
|
35
35
|
context "with a valid (known) delivery tag (multiple = true)" do
|
36
36
|
it "acknowledges a message" do
|
37
37
|
ch = connection.create_channel
|
38
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
38
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
39
39
|
x = ch.default_exchange
|
40
40
|
|
41
|
-
x.publish("bunneth", :
|
42
|
-
x.publish("bunneth", :
|
41
|
+
x.publish("bunneth", routing_key: q.name)
|
42
|
+
x.publish("bunneth", routing_key: q.name)
|
43
43
|
sleep 0.5
|
44
44
|
expect(q.message_count).to eq 2
|
45
|
-
delivery_details_1, _properties, _content = q.pop(:
|
46
|
-
delivery_details_2, _properties, _content = q.pop(:
|
45
|
+
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
46
|
+
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
47
47
|
|
48
48
|
ch.ack(delivery_details_2.delivery_tag, true)
|
49
49
|
ch.close
|
50
50
|
|
51
51
|
ch = connection.create_channel
|
52
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
52
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
53
53
|
expect(q.message_count).to eq 0
|
54
54
|
ch.close
|
55
55
|
end
|
@@ -58,21 +58,21 @@ describe Bunny::Channel, "#ack" do
|
|
58
58
|
context "with a valid (known) delivery tag (multiple = false)" do
|
59
59
|
it "acknowledges a message" do
|
60
60
|
ch = connection.create_channel
|
61
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
61
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
62
62
|
x = ch.default_exchange
|
63
63
|
|
64
|
-
x.publish("bunneth", :
|
65
|
-
x.publish("bunneth", :
|
64
|
+
x.publish("bunneth", routing_key: q.name)
|
65
|
+
x.publish("bunneth", routing_key: q.name)
|
66
66
|
sleep 0.5
|
67
67
|
expect(q.message_count).to eq 2
|
68
|
-
delivery_details_1, _properties, _content = q.pop(:
|
69
|
-
delivery_details_2, _properties, _content = q.pop(:
|
68
|
+
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
69
|
+
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
70
70
|
|
71
71
|
ch.ack(delivery_details_2.delivery_tag, false)
|
72
72
|
ch.close
|
73
73
|
|
74
74
|
ch = connection.create_channel
|
75
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
75
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
76
76
|
expect(q.message_count).to eq 1
|
77
77
|
ch.close
|
78
78
|
end
|
@@ -81,14 +81,14 @@ describe Bunny::Channel, "#ack" do
|
|
81
81
|
context "with a valid (known) delivery tag and automatic ack mode" do
|
82
82
|
it "results in a channel exception" do
|
83
83
|
ch = connection.create_channel
|
84
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
84
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
85
85
|
x = ch.default_exchange
|
86
86
|
|
87
|
-
q.subscribe(:
|
87
|
+
q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
|
88
88
|
ch.ack(delivery_info.delivery_tag, false)
|
89
89
|
end
|
90
90
|
|
91
|
-
x.publish("bunneth", :
|
91
|
+
x.publish("bunneth", routing_key: q.name)
|
92
92
|
sleep 0.5
|
93
93
|
expect do
|
94
94
|
q.message_count
|
@@ -99,13 +99,13 @@ describe Bunny::Channel, "#ack" do
|
|
99
99
|
context "with an invalid (random) delivery tag" do
|
100
100
|
it "causes a channel-level error" do
|
101
101
|
ch = connection.create_channel
|
102
|
-
q = ch.queue("bunny.basic.ack.unknown-delivery-tag", :
|
102
|
+
q = ch.queue("bunny.basic.ack.unknown-delivery-tag", exclusive: true)
|
103
103
|
x = ch.default_exchange
|
104
104
|
|
105
|
-
x.publish("bunneth", :
|
105
|
+
x.publish("bunneth", routing_key: q.name)
|
106
106
|
sleep 0.5
|
107
107
|
expect(q.message_count).to eq 1
|
108
|
-
_, _, content = q.pop(:
|
108
|
+
_, _, content = q.pop(manual_ack: true)
|
109
109
|
|
110
110
|
ch.on_error do |ch, channel_close|
|
111
111
|
@channel_close = channel_close
|
@@ -120,17 +120,17 @@ describe Bunny::Channel, "#ack" do
|
|
120
120
|
context "with a valid (known) delivery tag" do
|
121
121
|
it "gets a depricated message warning for using :ack" do
|
122
122
|
ch = connection.create_channel
|
123
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
123
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
124
124
|
x = ch.default_exchange
|
125
125
|
|
126
|
-
x.publish("bunneth", :
|
126
|
+
x.publish("bunneth", routing_key: q.name)
|
127
127
|
sleep 0.5
|
128
128
|
expect(q.message_count).to eq 1
|
129
129
|
|
130
130
|
orig_stderr = $stderr
|
131
131
|
$stderr = StringIO.new
|
132
132
|
|
133
|
-
delivery_details, properties, content = q.pop(:
|
133
|
+
delivery_details, properties, content = q.pop(ack: true)
|
134
134
|
|
135
135
|
$stderr.rewind
|
136
136
|
expect($stderr.string.chomp).to eq("[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead.\n[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead.")
|
@@ -141,7 +141,7 @@ describe Bunny::Channel, "#ack" do
|
|
141
141
|
ch.close
|
142
142
|
|
143
143
|
ch = connection.create_channel
|
144
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
144
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
145
145
|
expect(q.message_count).to eq 0
|
146
146
|
ch.close
|
147
147
|
end
|
@@ -150,7 +150,7 @@ end
|
|
150
150
|
|
151
151
|
describe Bunny::Channel, "#basic_ack" do
|
152
152
|
let(:connection) do
|
153
|
-
c = Bunny.new(:
|
153
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
154
154
|
c.start
|
155
155
|
c
|
156
156
|
end
|
@@ -162,21 +162,21 @@ describe Bunny::Channel, "#basic_ack" do
|
|
162
162
|
context "with a valid (known) delivery tag (multiple = true)" do
|
163
163
|
it "acknowledges a message" do
|
164
164
|
ch = connection.create_channel
|
165
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
165
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
166
166
|
x = ch.default_exchange
|
167
167
|
|
168
|
-
x.publish("bunneth", :
|
169
|
-
x.publish("bunneth", :
|
168
|
+
x.publish("bunneth", routing_key: q.name)
|
169
|
+
x.publish("bunneth", routing_key: q.name)
|
170
170
|
sleep 0.5
|
171
171
|
expect(q.message_count).to eq 2
|
172
|
-
delivery_details_1, _properties, _content = q.pop(:
|
173
|
-
delivery_details_2, _properties, _content = q.pop(:
|
172
|
+
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
173
|
+
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
174
174
|
|
175
175
|
ch.basic_ack(delivery_details_2.delivery_tag.to_i, true)
|
176
176
|
ch.close
|
177
177
|
|
178
178
|
ch = connection.create_channel
|
179
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
179
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
180
180
|
expect(q.message_count).to eq 0
|
181
181
|
ch.close
|
182
182
|
end
|
@@ -185,21 +185,21 @@ describe Bunny::Channel, "#basic_ack" do
|
|
185
185
|
context "with a valid (known) delivery tag (multiple = false)" do
|
186
186
|
it "acknowledges a message" do
|
187
187
|
ch = connection.create_channel
|
188
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
188
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
189
189
|
x = ch.default_exchange
|
190
190
|
|
191
|
-
x.publish("bunneth", :
|
192
|
-
x.publish("bunneth", :
|
191
|
+
x.publish("bunneth", routing_key: q.name)
|
192
|
+
x.publish("bunneth", routing_key: q.name)
|
193
193
|
sleep 0.5
|
194
194
|
expect(q.message_count).to eq 2
|
195
|
-
delivery_details_1, _properties, _content = q.pop(:
|
196
|
-
delivery_details_2, _properties, _content = q.pop(:
|
195
|
+
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
196
|
+
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
197
197
|
|
198
198
|
ch.basic_ack(delivery_details_2.delivery_tag.to_i, false)
|
199
199
|
ch.close
|
200
200
|
|
201
201
|
ch = connection.create_channel
|
202
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
202
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
203
203
|
expect(q.message_count).to eq 1
|
204
204
|
ch.close
|
205
205
|
end
|
@@ -208,21 +208,21 @@ describe Bunny::Channel, "#basic_ack" do
|
|
208
208
|
context "with a valid (known) delivery tag (multiple = default)" do
|
209
209
|
it "acknowledges a message" do
|
210
210
|
ch = connection.create_channel
|
211
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
211
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
212
212
|
x = ch.default_exchange
|
213
213
|
|
214
|
-
x.publish("bunneth", :
|
215
|
-
x.publish("bunneth", :
|
214
|
+
x.publish("bunneth", routing_key: q.name)
|
215
|
+
x.publish("bunneth", routing_key: q.name)
|
216
216
|
sleep 0.5
|
217
217
|
expect(q.message_count).to eq 2
|
218
|
-
delivery_details_1, _properties, _content = q.pop(:
|
219
|
-
delivery_details_2, _properties, _content = q.pop(:
|
218
|
+
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
219
|
+
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
220
220
|
|
221
221
|
ch.basic_ack(delivery_details_2.delivery_tag.to_i)
|
222
222
|
ch.close
|
223
223
|
|
224
224
|
ch = connection.create_channel
|
225
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :
|
225
|
+
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
226
226
|
expect(q.message_count).to eq 1
|
227
227
|
ch.close
|
228
228
|
end
|