bunny 0.10.8 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -4
  3. data/ChangeLog.md +1 -152
  4. data/Gemfile +1 -1
  5. data/README.md +5 -5
  6. data/bunny.gemspec +1 -1
  7. data/lib/bunny.rb +14 -2
  8. data/lib/bunny/channel.rb +94 -158
  9. data/lib/bunny/channel_id_allocator.rb +1 -2
  10. data/lib/bunny/concurrent/condition.rb +1 -2
  11. data/lib/bunny/concurrent/continuation_queue.rb +1 -1
  12. data/lib/bunny/consumer.rb +0 -13
  13. data/lib/bunny/consumer_work_pool.rb +2 -5
  14. data/lib/bunny/delivery_info.rb +1 -3
  15. data/lib/bunny/exceptions.rb +1 -4
  16. data/lib/bunny/heartbeat_sender.rb +1 -1
  17. data/lib/bunny/reader_loop.rb +3 -23
  18. data/lib/bunny/session.rb +19 -103
  19. data/lib/bunny/socket.rb +1 -1
  20. data/lib/bunny/transport.rb +7 -31
  21. data/lib/bunny/version.rb +1 -1
  22. data/spec/higher_level_api/integration/basic_ack_spec.rb +19 -34
  23. data/spec/higher_level_api/integration/basic_cancel_spec.rb +1 -1
  24. data/spec/higher_level_api/integration/basic_consume_spec.rb +2 -63
  25. data/spec/higher_level_api/integration/basic_get_spec.rb +1 -1
  26. data/spec/higher_level_api/integration/basic_nack_spec.rb +1 -1
  27. data/spec/higher_level_api/integration/basic_publish_spec.rb +1 -1
  28. data/spec/higher_level_api/integration/basic_qos_spec.rb +8 -5
  29. data/spec/higher_level_api/integration/basic_reject_spec.rb +17 -16
  30. data/spec/higher_level_api/integration/basic_return_spec.rb +1 -1
  31. data/spec/higher_level_api/integration/channel_close_spec.rb +10 -6
  32. data/spec/higher_level_api/integration/channel_flow_spec.rb +9 -6
  33. data/spec/higher_level_api/integration/channel_open_spec.rb +20 -11
  34. data/spec/higher_level_api/integration/confirm_select_spec.rb +1 -1
  35. data/spec/higher_level_api/integration/connection_spec.rb +1 -1
  36. data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +1 -1
  37. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +1 -46
  38. data/spec/higher_level_api/integration/dead_lettering_spec.rb +1 -1
  39. data/spec/higher_level_api/integration/exchange_bind_spec.rb +1 -1
  40. data/spec/higher_level_api/integration/exchange_declare_spec.rb +1 -1
  41. data/spec/higher_level_api/integration/exchange_delete_spec.rb +1 -1
  42. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +1 -1
  43. data/spec/higher_level_api/integration/merry_go_round_spec.rb +1 -1
  44. data/spec/higher_level_api/integration/message_properties_access_spec.rb +1 -1
  45. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
  46. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +1 -1
  47. data/spec/higher_level_api/integration/queue_declare_spec.rb +1 -1
  48. data/spec/higher_level_api/integration/queue_delete_spec.rb +2 -2
  49. data/spec/higher_level_api/integration/queue_purge_spec.rb +1 -1
  50. data/spec/higher_level_api/integration/queue_unbind_spec.rb +2 -2
  51. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +1 -1
  52. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +2 -2
  53. data/spec/higher_level_api/integration/tls_connection_spec.rb +2 -86
  54. data/spec/higher_level_api/integration/tx_commit_spec.rb +1 -1
  55. data/spec/higher_level_api/integration/tx_rollback_spec.rb +1 -1
  56. data/spec/unit/concurrent/condition_spec.rb +46 -53
  57. metadata +5 -25
  58. data/benchmarks/mutex_and_monitor.rb +0 -42
  59. data/benchmarks/synchronized_sorted_set.rb +0 -53
  60. data/lib/amq/protocol/extensions.rb +0 -16
  61. data/lib/bunny/concurrent/atomic_fixnum.rb +0 -74
  62. data/lib/bunny/concurrent/synchronized_sorted_set.rb +0 -56
  63. data/lib/bunny/timeout.rb +0 -18
  64. data/lib/bunny/versioned_delivery_tag.rb +0 -28
  65. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
  66. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  67. data/spec/issues/issue141_spec.rb +0 -44
  68. data/spec/stress/connection_open_close_spec.rb +0 -40
  69. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  70. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f535e615daf310f4a1e45b748799a0be9c7eb22d
4
- data.tar.gz: d12db49e5f7805b56b3d3a28dc0c42a5b64c49b7
3
+ metadata.gz: ae97d1a6c3f9bd4e72d67961007677f20b86636b
4
+ data.tar.gz: d7fd9c501d71379469e61f68e99d0d3292bc3b32
5
5
  SHA512:
6
- metadata.gz: 22a391ead25e9969d804a58452e3141606099c51b151b9985e8e2a3b3f116fda829aae2a340564d300b7d5533588fbaf0773a4d4444c5bda628bf1fafcf94384
7
- data.tar.gz: 035be3322b48d97b81a7655637fc63c51cae129fca10a32a159e2c35d21c3c174203d6ea4975c646318dee09a94a747b169379569b16d626cd69d2cd04e5ee7e
6
+ metadata.gz: c405d0617f646cffc2f5fb8ab9950277e1913ed131c6c7aeba95a8ac89742dfe5f56f24332753c7ed1de6ed7490affd33c619f0eaafa9dc6d76cc6c000c64233
7
+ data.tar.gz: 39cd8727b32ad97113fe5f5f07197da4c3b8fa884de2a86201c00603f2a5df7037a9778653ab19b20b4972e992f296e791fb15c13ffcfe25f42eaa3e517cd837
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  bundler_args: --without development
2
2
  before_script: "./bin/ci/before_build.sh"
3
- script: "bundle exec rspec -cfs spec"
3
+ script: "bundle exec rspec -c spec"
4
4
  rvm:
5
5
  - "2.0"
6
6
  - "1.9.3"
@@ -15,6 +15,3 @@ branches:
15
15
  only:
16
16
  - master
17
17
  - 0.9.x-stable
18
- matrix:
19
- allow_failures:
20
- - rvm: rbx-19mode
data/ChangeLog.md CHANGED
@@ -1,155 +1,4 @@
1
- ## Changes between Bunny 0.10.6 and 0.10.7
2
-
3
- ### Add timeout Bunny::ConsumerWorkPool#join
4
-
5
- `Bunny::ConsumerWorkPool#join` now accepts an optional
6
- timeout argument.
7
-
8
-
9
- ## Changes between Bunny 0.10.5 and 0.10.6
10
-
11
- ### Respect RABBITMQ_URL value
12
-
13
- `RABBITMQ_URL` env variable will now have effect even if
14
- Bunny.new is invoked without arguments.
15
-
16
- Contributed by Robert Ross.
17
-
18
-
19
- ## Changes between Bunny 0.10.4 and 0.10.5
20
-
21
- ### Bunny::Session.parse_uri
22
-
23
- `Bunny::Session.parse_uri` is a new method that parses
24
- connection URIs into hashes that `Bunny::Session#initialize`
25
- accepts.
26
-
27
- ``` ruby
28
- Bunny::Session.parse_uri("amqp://user:pwd@broker.eng.megacorp.local/myapp_qa")
29
- ```
30
-
31
-
32
- ## Changes between Bunny 0.10.3 and 0.10.4
33
-
34
- ### Default Paths for TLS/SSL CA's on All OS'es
35
-
36
- Bunny now uses OpenSSL to detect default TLS/SSL CA's paths, extending
37
- this feature to OS'es other than Linux.
38
-
39
- Contributed by Jingwen Owen Ou.
40
-
41
-
42
- ## Changes between Bunny 0.10.2 and 0.10.3
43
-
44
- ### Default Paths for TLS/SSL CA's on Linux
45
-
46
- Bunny now will use the following TLS/SSL CA's paths on Linux by default:
47
-
48
- * `/etc/ssl/certs/ca-certificates.crt` on Ubuntu/Debian
49
- * `/etc/ssl/certs/ca-bundle.crt` on Amazon Linux
50
- * `/etc/ssl/ca-bundle.pem` on OpenSUSE
51
- * `/etc/pki/tls/certs/ca-bundle.crt` on Fedora/RHEL
52
-
53
- and will log a warning if no CA files are available via default paths
54
- or `:tls_ca_certificates`.
55
-
56
- Contributed by Carl Hörberg.
57
-
58
-
59
- ## Changes between Bunny 0.10.1 and 0.10.2
60
-
61
- ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
62
-
63
- It is now possible to re-register a consumer (and use any other synchronous methods)
64
- from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
65
- thread pool.
66
-
67
-
68
- ### Bunny::Session#close Fixed for Single Threaded Connections
69
-
70
- `Bunny::Session#close` with single threaded connections no longer fails
71
- with a nil pointer exception.
72
-
73
-
74
-
75
- ## Changes between Bunny 0.10.0 and 0.10.1
76
-
77
- ### Fix Abnormally Slow Bunny::Connection#close on JRuby
78
-
79
- `Bunny::Connection#close` on JRuby sometimes could enter a waiting
80
- state [on a native NIO/kqueue method] that lasted up to over 10 seconds.
81
-
82
- This severely affected test suite run times.
83
-
84
-
85
- ## Changes between Bunny 0.9.0 and 0.10.0
86
-
87
- This release has one minor **breaking API change**.
88
-
89
- ### Safe[r] basic.ack, basic.nack and basic.reject implementation
90
-
91
- Previously if a channel was recovered (reopened) by automatic connection
92
- recovery before a message was acknowledged or rejected, it would cause
93
- any operation on the channel that uses delivery tags to fail and
94
- cause the channel to be closed.
95
-
96
- To avoid this issue, every channel keeps a counter of how many times
97
- it has been reopened and marks delivery tags with them. Using a stale
98
- tag to ack or reject a message will produce no method sent to RabbitMQ.
99
- Note that unacknowledged messages will be requeued by RabbitMQ when connection
100
- goes down anyway.
101
-
102
- This involves an API change: `Bunny::DeliveryMetadata#delivery_tag` is now
103
- and instance of a class that responds to `#tag` and `#to_i` and is accepted
104
- by `Bunny::Channel#ack` and related methods.
105
-
106
- Integers are still accepted by the same methods.
107
-
108
-
109
- ### Exclusivity Violation for Consumers Now Raises a Reasonable Exception
110
-
111
- When a second consumer is registered for the same queue on different channels,
112
- a reasonable exception (`Bunny::AccessRefused`) will be raised.
113
-
114
-
115
- ### Reentrant Mutex Implementation
116
-
117
- Bunny now allows mutex impl to be configurable, uses reentrant Monitor
118
- by default.
119
-
120
- Non-reentrant mutexes is a major PITA and may affect code that
121
- uses Bunny.
122
-
123
- Avg. publishing throughput with Monitor drops slightly from
124
- 5.73 Khz to 5.49 Khz (about 4% decrease), which is reasonable
125
- for Bunny.
126
-
127
- Apps that need these 4% can configure what mutex implementation
128
- is used on per-connection basis.
129
-
130
- ### Eliminated Race Condition in Bunny::Session#close
131
-
132
- `Bunny::Session#close` had a race condition that caused (non-deterministic)
133
- exceptions when connection transport was closed before connection
134
- reader loop was guaranteed to have stopped.
135
-
136
- ### connection.close Raises Exceptions on Connection Thread
137
-
138
- Connection-level exceptions (including when a connection is closed via
139
- management UI or `rabbitmqctl`) will now be raised on the connection
140
- thread so they
141
-
142
- * can be handled by applications
143
- * do not start connection recovery, which may be uncalled for
144
-
145
- ### Client TLS Certificates are Optional
146
-
147
- Bunny will no longer require client TLS certificates. Note that CA certificate
148
- list is still necessary.
149
-
150
- If RabbitMQ TLS configuration requires peer verification, client certificate
151
- and private key are mandatory.
152
-
1
+ ## Changes between Bunny 0.9.0 and 1.0.0.pre1
153
2
 
154
3
  ### Publishing Over Closed Connections
155
4
 
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ extend Module.new {
19
19
  end
20
20
  }
21
21
 
22
- gem "SystemTimer", "~> 1.2.3", :platform => :ruby_18
22
+ gem "SystemTimer", "1.2", :platform => :ruby_18
23
23
 
24
24
  gem "rake", ">= 10.0.4"
25
25
  gem "effin_utf8"
data/README.md CHANGED
@@ -79,7 +79,7 @@ backwards compatible as possible but within reason.
79
79
 
80
80
  ### With Rubygems
81
81
 
82
- To install Bunny with RubyGems:
82
+ To install Bunny 0.9.x with RubyGems:
83
83
 
84
84
  ```
85
85
  gem install bunny
@@ -87,17 +87,17 @@ gem install bunny
87
87
 
88
88
  ### Bundler Dependency
89
89
 
90
- To use Bunny in a project managed with Bundler:
90
+ To use Bunny 0.9.x in a project managed with Bundler:
91
91
 
92
92
  ``` ruby
93
- gem "bunny", ">= 0.10.7"
93
+ gem "bunny", ">= 0.9.3"
94
94
  ```
95
95
 
96
96
 
97
- ## Quick Start
97
+ ## Quick Start for Bunny 0.9.x
98
98
 
99
99
  Below is a small snippet that demonstrates how to publish
100
- and synchronously consume ("pull API") messages with Bunny.
100
+ and synchronously consume ("pull API") messages with Bunny 0.9.
101
101
 
102
102
  For a 15 minute tutorial using more practical examples, see [Getting Started with RabbitMQ and Ruby using Bunny](http://rubybunny.info/articles/getting_started.html).
103
103
 
data/bunny.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.version = Bunny::VERSION.dup
10
10
  s.homepage = "http://rubybunny.info"
11
11
  s.summary = "Popular easy to use Ruby client for RabbitMQ"
12
- s.description = "Easy to use, feature complete Ruby client for RabbitMQ 2.0 and later versions."
12
+ s.description = "Easy to use, feature complete Ruby client for RabbitMQ 2.0."
13
13
  s.license = "MIT"
14
14
 
15
15
  # Sorted alphabetically.
data/lib/bunny.rb CHANGED
@@ -4,12 +4,10 @@ require "timeout"
4
4
 
5
5
  require "bunny/version"
6
6
  require "amq/protocol/client"
7
- require "amq/protocol/extensions"
8
7
 
9
8
  require "bunny/framing"
10
9
  require "bunny/exceptions"
11
10
  require "bunny/socket"
12
- require "bunny/timeout"
13
11
 
14
12
  begin
15
13
  require "openssl"
@@ -34,6 +32,20 @@ module Bunny
34
32
  # AMQP protocol version Bunny implements
35
33
  PROTOCOL_VERSION = AMQ::Protocol::PROTOCOL_VERSION
36
34
 
35
+ # unifies Ruby standard library's Timeout (which is not accurate on
36
+ # Ruby 1.8 and has other issues) and SystemTimer (the gem)
37
+ Timer = if RUBY_VERSION < "1.9"
38
+ begin
39
+ require "bunny/system_timer"
40
+ Bunny::SystemTimer
41
+ rescue LoadError
42
+ Timeout
43
+ end
44
+ else
45
+ Timeout
46
+ end
47
+
48
+
37
49
  #
38
50
  # API
39
51
  #
data/lib/bunny/channel.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "thread"
3
- require "monitor"
4
3
  require "set"
5
4
 
6
- require "bunny/concurrent/atomic_fixnum"
7
5
  require "bunny/consumer_work_pool"
8
6
 
9
7
  require "bunny/exchange"
@@ -175,10 +173,10 @@ module Bunny
175
173
  @work_pool = work_pool
176
174
 
177
175
  # synchronizes frameset delivery. MK.
178
- @publishing_mutex = @connection.mutex_impl.new
179
- @consumer_mutex = @connection.mutex_impl.new
176
+ @publishing_mutex = Mutex.new
177
+ @consumer_mutex = Mutex.new
180
178
 
181
- @unconfirmed_set_mutex = @connection.mutex_impl.new
179
+ @unconfirmed_set_mutex = Mutex.new
182
180
 
183
181
  self.reset_continuations
184
182
 
@@ -190,12 +188,8 @@ module Bunny
190
188
  @threads_waiting_on_basic_get_continuations = Set.new
191
189
 
192
190
  @next_publish_seq_no = 0
193
-
194
- @recoveries_counter = Bunny::Concurrent::AtomicFixnum.new(0)
195
191
  end
196
192
 
197
- attr_reader :recoveries_counter
198
-
199
193
  # @private
200
194
  def read_write_timeout
201
195
  @connection.read_write_timeout
@@ -443,9 +437,7 @@ module Bunny
443
437
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
444
438
  # @api public
445
439
  def reject(delivery_tag, requeue = false)
446
- guarding_against_stale_delivery_tags(delivery_tag) do
447
- basic_reject(delivery_tag.to_i, requeue)
448
- end
440
+ basic_reject(delivery_tag, requeue)
449
441
  end
450
442
 
451
443
  # Acknowledges a message. Acknowledged messages are completely removed from the queue.
@@ -456,9 +448,7 @@ module Bunny
456
448
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
457
449
  # @api public
458
450
  def ack(delivery_tag, multiple = false)
459
- guarding_against_stale_delivery_tags(delivery_tag) do
460
- basic_ack(delivery_tag.to_i, multiple)
461
- end
451
+ basic_ack(delivery_tag, multiple)
462
452
  end
463
453
  alias acknowledge ack
464
454
 
@@ -473,9 +463,7 @@ module Bunny
473
463
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
474
464
  # @api public
475
465
  def nack(delivery_tag, multiple = false, requeue = false)
476
- guarding_against_stale_delivery_tags(delivery_tag) do
477
- basic_nack(delivery_tag.to_i, multiple, requeue)
478
- end
466
+ basic_nack(delivery_tag, multiple, requeue)
479
467
  end
480
468
 
481
469
  # @endgroup
@@ -533,13 +521,13 @@ module Bunny
533
521
  end
534
522
 
535
523
  m = AMQ::Protocol::Basic::Publish.encode(@id,
536
- payload,
537
- meta,
538
- exchange_name,
539
- routing_key,
540
- meta[:mandatory],
541
- false,
542
- @connection.frame_max)
524
+ payload,
525
+ meta,
526
+ exchange_name,
527
+ routing_key,
528
+ meta[:mandatory],
529
+ false,
530
+ @connection.frame_max)
543
531
  @connection.send_frameset_without_timeout(m, self)
544
532
 
545
533
  self
@@ -602,7 +590,7 @@ module Bunny
602
590
 
603
591
  @connection.send_frame(AMQ::Protocol::Basic::Qos.encode(@id, 0, prefetch_count, global))
604
592
 
605
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
593
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
606
594
  @last_basic_qos_ok = wait_on_continuations
607
595
  end
608
596
  raise_if_continuation_resulted_in_a_channel_error!
@@ -621,7 +609,7 @@ module Bunny
621
609
  raise_if_no_longer_open!
622
610
 
623
611
  @connection.send_frame(AMQ::Protocol::Basic::Recover.encode(@id, requeue))
624
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
612
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
625
613
  @last_basic_recover_ok = wait_on_continuations
626
614
  end
627
615
  raise_if_continuation_resulted_in_a_channel_error!
@@ -712,7 +700,6 @@ module Bunny
712
700
  # ch.basic_ack(delivery_info.delivery_tag, true)
713
701
  #
714
702
  # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
715
- # @see #basic_ack_known_delivery_tag
716
703
  # @api public
717
704
  def basic_ack(delivery_tag, multiple)
718
705
  raise_if_no_longer_open!
@@ -777,9 +764,9 @@ module Bunny
777
764
  def basic_nack(delivery_tag, multiple = false, requeue = false)
778
765
  raise_if_no_longer_open!
779
766
  @connection.send_frame(AMQ::Protocol::Basic::Nack.encode(@id,
780
- delivery_tag,
781
- multiple,
782
- requeue))
767
+ delivery_tag,
768
+ multiple,
769
+ requeue))
783
770
 
784
771
  nil
785
772
  end
@@ -814,16 +801,16 @@ module Bunny
814
801
  end
815
802
 
816
803
  @connection.send_frame(AMQ::Protocol::Basic::Consume.encode(@id,
817
- queue_name,
818
- consumer_tag,
819
- false,
820
- no_ack,
821
- exclusive,
822
- false,
823
- arguments))
804
+ queue_name,
805
+ consumer_tag,
806
+ false,
807
+ no_ack,
808
+ exclusive,
809
+ false,
810
+ arguments))
824
811
 
825
812
  begin
826
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
813
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
827
814
  @last_basic_consume_ok = wait_on_continuations
828
815
  end
829
816
  rescue Exception => e
@@ -834,16 +821,11 @@ module Bunny
834
821
  raise e
835
822
  end
836
823
 
837
- # in case there is another exclusive consumer and we get a channel.close
838
- # response here. MK.
839
- raise_if_channel_close!(@last_basic_consume_ok)
840
-
841
824
  # covers server-generated consumer tags
842
825
  add_consumer(queue_name, @last_basic_consume_ok.consumer_tag, no_ack, exclusive, arguments, &block)
843
826
 
844
827
  @last_basic_consume_ok
845
828
  end
846
- alias consume basic_consume
847
829
 
848
830
  # Registers a consumer for queue as {Bunny::Consumer} instance.
849
831
  #
@@ -864,16 +846,16 @@ module Bunny
864
846
  end
865
847
 
866
848
  @connection.send_frame(AMQ::Protocol::Basic::Consume.encode(@id,
867
- consumer.queue_name,
868
- consumer.consumer_tag,
869
- false,
870
- consumer.no_ack,
871
- consumer.exclusive,
872
- false,
873
- consumer.arguments))
849
+ consumer.queue_name,
850
+ consumer.consumer_tag,
851
+ false,
852
+ consumer.no_ack,
853
+ consumer.exclusive,
854
+ false,
855
+ consumer.arguments))
874
856
 
875
857
  begin
876
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
858
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
877
859
  @last_basic_consume_ok = wait_on_continuations
878
860
  end
879
861
  rescue Exception => e
@@ -884,10 +866,6 @@ module Bunny
884
866
  raise e
885
867
  end
886
868
 
887
- # in case there is another exclusive consumer and we get a channel.close
888
- # response here. MK.
889
- raise_if_channel_close!(@last_basic_consume_ok)
890
-
891
869
  # covers server-generated consumer tags
892
870
  register_consumer(@last_basic_consume_ok.consumer_tag, consumer)
893
871
 
@@ -895,7 +873,6 @@ module Bunny
895
873
 
896
874
  @last_basic_consume_ok
897
875
  end
898
- alias consume_with basic_consume_with
899
876
 
900
877
  # Removes a consumer. Messages for this consumer will no longer be delivered. If the queue
901
878
  # it was on is auto-deleted and this consumer was the last one, the queue will be deleted.
@@ -908,7 +885,7 @@ module Bunny
908
885
  def basic_cancel(consumer_tag)
909
886
  @connection.send_frame(AMQ::Protocol::Basic::Cancel.encode(@id, consumer_tag, false))
910
887
 
911
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
888
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
912
889
  @last_basic_cancel_ok = wait_on_continuations
913
890
  end
914
891
 
@@ -949,13 +926,13 @@ module Bunny
949
926
  raise_if_no_longer_open!
950
927
 
951
928
  @connection.send_frame(AMQ::Protocol::Queue::Declare.encode(@id,
952
- name,
953
- opts.fetch(:passive, false),
954
- opts.fetch(:durable, false),
955
- opts.fetch(:exclusive, false),
956
- opts.fetch(:auto_delete, false),
957
- false,
958
- opts[:arguments]))
929
+ name,
930
+ opts.fetch(:passive, false),
931
+ opts.fetch(:durable, false),
932
+ opts.fetch(:exclusive, false),
933
+ opts.fetch(:auto_delete, false),
934
+ false,
935
+ opts[:arguments]))
959
936
  @last_queue_declare_ok = wait_on_continuations
960
937
 
961
938
  raise_if_continuation_resulted_in_a_channel_error!
@@ -978,11 +955,11 @@ module Bunny
978
955
  raise_if_no_longer_open!
979
956
 
980
957
  @connection.send_frame(AMQ::Protocol::Queue::Delete.encode(@id,
981
- name,
982
- opts[:if_unused],
983
- opts[:if_empty],
984
- false))
985
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
958
+ name,
959
+ opts[:if_unused],
960
+ opts[:if_empty],
961
+ false))
962
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
986
963
  @last_queue_delete_ok = wait_on_continuations
987
964
  end
988
965
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1002,7 +979,7 @@ module Bunny
1002
979
 
1003
980
  @connection.send_frame(AMQ::Protocol::Queue::Purge.encode(@id, name, false))
1004
981
 
1005
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
982
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1006
983
  @last_queue_purge_ok = wait_on_continuations
1007
984
  end
1008
985
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1033,12 +1010,12 @@ module Bunny
1033
1010
  end
1034
1011
 
1035
1012
  @connection.send_frame(AMQ::Protocol::Queue::Bind.encode(@id,
1036
- name,
1037
- exchange_name,
1038
- opts[:routing_key],
1039
- false,
1040
- opts[:arguments]))
1041
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1013
+ name,
1014
+ exchange_name,
1015
+ opts[:routing_key],
1016
+ false,
1017
+ opts[:arguments]))
1018
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1042
1019
  @last_queue_bind_ok = wait_on_continuations
1043
1020
  end
1044
1021
 
@@ -1069,11 +1046,11 @@ module Bunny
1069
1046
  end
1070
1047
 
1071
1048
  @connection.send_frame(AMQ::Protocol::Queue::Unbind.encode(@id,
1072
- name,
1073
- exchange_name,
1074
- opts[:routing_key],
1075
- opts[:arguments]))
1076
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1049
+ name,
1050
+ exchange_name,
1051
+ opts[:routing_key],
1052
+ opts[:arguments]))
1053
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1077
1054
  @last_queue_unbind_ok = wait_on_continuations
1078
1055
  end
1079
1056
 
@@ -1104,15 +1081,15 @@ module Bunny
1104
1081
  raise_if_no_longer_open!
1105
1082
 
1106
1083
  @connection.send_frame(AMQ::Protocol::Exchange::Declare.encode(@id,
1107
- name,
1108
- type.to_s,
1109
- opts.fetch(:passive, false),
1110
- opts.fetch(:durable, false),
1111
- opts.fetch(:auto_delete, false),
1112
- false,
1113
- false,
1114
- opts[:arguments]))
1115
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1084
+ name,
1085
+ type.to_s,
1086
+ opts.fetch(:passive, false),
1087
+ opts.fetch(:durable, false),
1088
+ opts.fetch(:auto_delete, false),
1089
+ false,
1090
+ false,
1091
+ opts[:arguments]))
1092
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1116
1093
  @last_exchange_declare_ok = wait_on_continuations
1117
1094
  end
1118
1095
 
@@ -1134,10 +1111,10 @@ module Bunny
1134
1111
  raise_if_no_longer_open!
1135
1112
 
1136
1113
  @connection.send_frame(AMQ::Protocol::Exchange::Delete.encode(@id,
1137
- name,
1138
- opts[:if_unused],
1139
- false))
1140
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1114
+ name,
1115
+ opts[:if_unused],
1116
+ false))
1117
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1141
1118
  @last_exchange_delete_ok = wait_on_continuations
1142
1119
  end
1143
1120
 
@@ -1176,12 +1153,12 @@ module Bunny
1176
1153
  end
1177
1154
 
1178
1155
  @connection.send_frame(AMQ::Protocol::Exchange::Bind.encode(@id,
1179
- destination_name,
1180
- source_name,
1181
- opts[:routing_key],
1182
- false,
1183
- opts[:arguments]))
1184
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1156
+ destination_name,
1157
+ source_name,
1158
+ opts[:routing_key],
1159
+ false,
1160
+ opts[:arguments]))
1161
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1185
1162
  @last_exchange_bind_ok = wait_on_continuations
1186
1163
  end
1187
1164
 
@@ -1220,12 +1197,12 @@ module Bunny
1220
1197
  end
1221
1198
 
1222
1199
  @connection.send_frame(AMQ::Protocol::Exchange::Unbind.encode(@id,
1223
- destination_name,
1224
- source_name,
1225
- opts[:routing_key],
1226
- false,
1227
- opts[:arguments]))
1228
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1200
+ destination_name,
1201
+ source_name,
1202
+ opts[:routing_key],
1203
+ false,
1204
+ opts[:arguments]))
1205
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1229
1206
  @last_exchange_unbind_ok = wait_on_continuations
1230
1207
  end
1231
1208
 
@@ -1253,7 +1230,7 @@ module Bunny
1253
1230
  raise_if_no_longer_open!
1254
1231
 
1255
1232
  @connection.send_frame(AMQ::Protocol::Channel::Flow.encode(@id, active))
1256
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1233
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1257
1234
  @last_channel_flow_ok = wait_on_continuations
1258
1235
  end
1259
1236
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1274,7 +1251,7 @@ module Bunny
1274
1251
  raise_if_no_longer_open!
1275
1252
 
1276
1253
  @connection.send_frame(AMQ::Protocol::Tx::Select.encode(@id))
1277
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1254
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1278
1255
  @last_tx_select_ok = wait_on_continuations
1279
1256
  end
1280
1257
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1289,7 +1266,7 @@ module Bunny
1289
1266
  raise_if_no_longer_open!
1290
1267
 
1291
1268
  @connection.send_frame(AMQ::Protocol::Tx::Commit.encode(@id))
1292
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1269
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1293
1270
  @last_tx_commit_ok = wait_on_continuations
1294
1271
  end
1295
1272
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1304,7 +1281,7 @@ module Bunny
1304
1281
  raise_if_no_longer_open!
1305
1282
 
1306
1283
  @connection.send_frame(AMQ::Protocol::Tx::Rollback.encode(@id))
1307
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1284
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1308
1285
  @last_tx_rollback_ok = wait_on_continuations
1309
1286
  end
1310
1287
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1344,7 +1321,7 @@ module Bunny
1344
1321
  @confirms_callback = callback
1345
1322
 
1346
1323
  @connection.send_frame(AMQ::Protocol::Confirm::Select.encode(@id, false))
1347
- Bunny::Timeout.timeout(read_write_timeout, ClientTimeout) do
1324
+ Bunny::Timer.timeout(read_write_timeout, ClientTimeout) do
1348
1325
  @last_confirm_select_ok = wait_on_continuations
1349
1326
  end
1350
1327
  raise_if_continuation_resulted_in_a_channel_error!
@@ -1421,7 +1398,6 @@ module Bunny
1421
1398
  # this includes recovering bindings
1422
1399
  recover_queues
1423
1400
  recover_consumers
1424
- increment_recoveries_counter
1425
1401
  end
1426
1402
 
1427
1403
  # Recovers basic.qos setting. Used by the Automatic Network Failure
@@ -1467,11 +1443,6 @@ module Bunny
1467
1443
  end
1468
1444
  end
1469
1445
 
1470
- # @private
1471
- def increment_recoveries_counter
1472
- @recoveries_counter.increment
1473
- end
1474
-
1475
1446
  # @endgroup
1476
1447
 
1477
1448
 
@@ -1540,17 +1511,10 @@ module Bunny
1540
1511
  @continuations.push(method)
1541
1512
  when AMQ::Protocol::Basic::Cancel then
1542
1513
  if consumer = @consumers[method.consumer_tag]
1543
- @work_pool.submit do
1544
- begin
1545
- @consumers.delete(method.consumer_tag)
1546
- consumer.handle_cancellation(method)
1547
- rescue Exception => e
1548
- @logger.error "Got excepton when notifying consumer #{method.consumer_tag} about cancellation!"
1549
- end
1550
- end
1551
- else
1552
- @logger.warn "No consumer for tag #{method.consumer_tag} on channel #{@id}!"
1514
+ consumer.handle_cancellation(method)
1553
1515
  end
1516
+
1517
+ @consumers.delete(method.consumer_tag)
1554
1518
  when AMQ::Protocol::Basic::CancelOk then
1555
1519
  @continuations.push(method)
1556
1520
  unregister_consumer(method.consumer_tag)
@@ -1590,7 +1554,6 @@ module Bunny
1590
1554
 
1591
1555
  # @private
1592
1556
  def handle_basic_get_ok(basic_get_ok, properties, content)
1593
- basic_get_ok.delivery_tag = VersionedDeliveryTag.new(basic_get_ok.delivery_tag, @recoveries_counter.get)
1594
1557
  @basic_get_continuations.push([basic_get_ok, properties, content])
1595
1558
  end
1596
1559
 
@@ -1642,8 +1605,10 @@ module Bunny
1642
1605
 
1643
1606
  @unconfirmed_set_mutex.synchronize do
1644
1607
  @only_acks_received = (@only_acks_received && !nack)
1608
+ @logger.debug "Channel #{@id}: @only_acks_received = #{@only_acks_received.inspect}, nack: #{nack.inspect}"
1645
1609
 
1646
1610
  @confirms_continuations.push(true) if @unconfirmed_set.empty?
1611
+
1647
1612
  @confirms_callback.call(delivery_tag, multiple, nack) if @confirms_callback
1648
1613
  end
1649
1614
  end
@@ -1820,19 +1785,6 @@ module Bunny
1820
1785
  raise ChannelAlreadyClosed.new("cannot use a channel that was already closed! Channel id: #{@id}", self) if closed?
1821
1786
  end
1822
1787
 
1823
- # @private
1824
- def raise_if_channel_close!(method)
1825
- if method && method.is_a?(AMQ::Protocol::Channel::Close)
1826
- # basic.ack, basic.reject, basic.nack. MK.
1827
- if channel_level_exception_after_operation_that_has_no_response?(method)
1828
- @on_error.call(self, method) if @on_error
1829
- else
1830
- @last_channel_error = instantiate_channel_level_exception(method)
1831
- raise @last_channel_error
1832
- end
1833
- end
1834
- end
1835
-
1836
1788
  # @private
1837
1789
  def reset_continuations
1838
1790
  @continuations = new_continuation
@@ -1852,21 +1804,5 @@ module Bunny
1852
1804
  Concurrent::ContinuationQueue.new
1853
1805
  end
1854
1806
  end # if defined?
1855
-
1856
- # @private
1857
- def guarding_against_stale_delivery_tags(tag, &block)
1858
- case tag
1859
- # if a fixnum was passed, execute unconditionally. MK.
1860
- when Fixnum then
1861
- block.call
1862
- # versioned delivery tags should be checked to avoid
1863
- # sending out stale (invalid) tags after channel was reopened
1864
- # during network failure recovery. MK.
1865
- when VersionedDeliveryTag then
1866
- if !tag.stale?(@recoveries_counter.get)
1867
- block.call
1868
- end
1869
- end
1870
- end
1871
1807
  end # Channel
1872
1808
  end # Bunny