bunny 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3e5ee2f2801f1420033324361e8fe9768a48e7e
4
- data.tar.gz: b1f35041c2d32444ab5290301cbab613c4d63abd
3
+ metadata.gz: f5f79488e6b65537ea12c2a0675e23f22b954f04
4
+ data.tar.gz: ececfcb8dc3374af17d6a2e9265a6b4a1fa02d8a
5
5
  SHA512:
6
- metadata.gz: 35622fd832fd559a594c7eb1bbb46576f1831d34c4bb2a1b9e4ee86e58500afa39e179785388aba9ca3a9311665f193b06d96b10429be7bc33dd6d54f98de706
7
- data.tar.gz: 9f39c1e15d01f1a09f617a411f7d157028e2efe4cb4eb905564f73a08ff956e2fbbfdb0cb71cb9087aca7b0f3c0082fee348dc9ba41764876d857f2a14fdf7a2
6
+ metadata.gz: 39577f8e482fc0fdbd727077c82747a262f97967c3e8e8027a410a2bc08cf41cf45edd46f383c1128f308c40c4602ecfaf64d56323cba3d8528582706f3ee292
7
+ data.tar.gz: c22ca1d276aaa7d9dd992040366dcb3d27179dadc10c7204de1e2e75a8f641de955755a0118feb874507e9c3ee7a883a361787251fdea8834c59647cb7fc4719
@@ -1,3 +1,26 @@
1
+ ## Changes between Bunny 0.10.1 and 0.10.2
2
+
3
+ ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
4
+
5
+ It is now possible to re-register a consumer (and use any other synchronous methods)
6
+ from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
7
+ thread pool.
8
+
9
+
10
+ ### Consumers Can Be Re-Registered From Bunny::Consumer#handle_cancellation
11
+
12
+ It is now possible to re-register a consumer (and use any other synchronous methods)
13
+ from `Bunny::Consumer#handle_cancellation`, which is now invoked in the channel's
14
+ thread pool.
15
+
16
+
17
+ ### Bunny::Session#close Fixed for Single Threaded Connections
18
+
19
+ `Bunny::Session#close` with single threaded connections no longer fails
20
+ with a nil pointer exception.
21
+
22
+
23
+
1
24
  ## Changes between Bunny 0.10.0 and 0.10.1
2
25
 
3
26
  ### Fix Abnormally Slow Bunny::Connection#close on JRuby
@@ -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."
12
+ s.description = "Easy to use, feature complete Ruby client for RabbitMQ 2.0 and later versions."
13
13
  s.license = "MIT"
14
14
 
15
15
  # Sorted alphabetically.
@@ -843,6 +843,7 @@ module Bunny
843
843
 
844
844
  @last_basic_consume_ok
845
845
  end
846
+ alias consume basic_consume
846
847
 
847
848
  # Registers a consumer for queue as {Bunny::Consumer} instance.
848
849
  #
@@ -894,6 +895,7 @@ module Bunny
894
895
 
895
896
  @last_basic_consume_ok
896
897
  end
898
+ alias consume_with basic_consume_with
897
899
 
898
900
  # Removes a consumer. Messages for this consumer will no longer be delivered. If the queue
899
901
  # it was on is auto-deleted and this consumer was the last one, the queue will be deleted.
@@ -1538,10 +1540,17 @@ module Bunny
1538
1540
  @continuations.push(method)
1539
1541
  when AMQ::Protocol::Basic::Cancel then
1540
1542
  if consumer = @consumers[method.consumer_tag]
1541
- consumer.handle_cancellation(method)
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}!"
1542
1553
  end
1543
-
1544
- @consumers.delete(method.consumer_tag)
1545
1554
  when AMQ::Protocol::Basic::CancelOk then
1546
1555
  @continuations.push(method)
1547
1556
  unregister_consumer(method.consumer_tag)
@@ -1847,12 +1856,12 @@ module Bunny
1847
1856
  # @private
1848
1857
  def guarding_against_stale_delivery_tags(tag, &block)
1849
1858
  case tag
1850
- # if a fixnum was passed, execute unconditionally. MK.
1859
+ # if a fixnum was passed, execute unconditionally. MK.
1851
1860
  when Fixnum then
1852
1861
  block.call
1853
- # versioned delivery tags should be checked to avoid
1854
- # sending out stale (invalid) tags after channel was reopened
1855
- # during network failure recovery. MK.
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.
1856
1865
  when VersionedDeliveryTag then
1857
1866
  if !tag.stale?(@recoveries_counter.get)
1858
1867
  block.call
@@ -91,16 +91,18 @@ module Bunny
91
91
  end
92
92
 
93
93
  def raise(e)
94
- @thread.raise(e)
94
+ @thread.raise(e) if @thread
95
95
  end
96
96
 
97
97
  def join
98
- @thread.join
98
+ @thread.join if @thread
99
99
  end
100
100
 
101
101
  def kill
102
- @thread.kill
103
- @thread.join
102
+ if @thread
103
+ @thread.kill
104
+ @thread.join
105
+ end
104
106
  end
105
107
 
106
108
  def log_exception(e)
@@ -226,7 +226,7 @@ module Bunny
226
226
  self.open_connection
227
227
 
228
228
  @reader_loop = nil
229
- self.start_reader_loop if @threaded
229
+ self.start_reader_loop if threaded?
230
230
 
231
231
  @default_channel = self.create_channel
232
232
  rescue Exception => e
@@ -269,9 +269,7 @@ module Bunny
269
269
  self.close_connection(true)
270
270
  end
271
271
 
272
- # puts "before maybe_shutdown_reader_loop"
273
272
  maybe_shutdown_reader_loop
274
- # puts "after maybe_shutdown_reader_loop"
275
273
  close_transport
276
274
 
277
275
  @status = :closed
@@ -628,18 +626,22 @@ module Bunny
628
626
  def maybe_shutdown_reader_loop
629
627
  if @reader_loop
630
628
  @reader_loop.stop
631
- # this is the easiest way to wait until the loop
632
- # is guaranteed to have terminated
633
- @reader_loop.raise(ShutdownSignal)
634
- # joining the thread here may take forever
635
- # on JRuby because sun.nio.ch.KQueueArrayWrapper#kevent0 is
636
- # a native method that cannot be (easily) interrupted.
637
- # So we use this ugly hack or else our test suite takes forever
638
- # to run on JRuby (a new connection is opened/closed per example). MK.
639
- if RUBY_ENGINE == "jruby"
640
- sleep 0.075
629
+ if threaded?
630
+ # this is the easiest way to wait until the loop
631
+ # is guaranteed to have terminated
632
+ @reader_loop.raise(ShutdownSignal)
633
+ # joining the thread here may take forever
634
+ # on JRuby because sun.nio.ch.KQueueArrayWrapper#kevent0 is
635
+ # a native method that cannot be (easily) interrupted.
636
+ # So we use this ugly hack or else our test suite takes forever
637
+ # to run on JRuby (a new connection is opened/closed per example). MK.
638
+ if RUBY_ENGINE == "jruby"
639
+ sleep 0.075
640
+ else
641
+ @reader_loop.join
642
+ end
641
643
  else
642
- @reader_loop.join
644
+ # single threaded mode, nothing to do. MK.
643
645
  end
644
646
  end
645
647
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "0.10.1"
5
+ VERSION = "0.10.2"
6
6
  end
@@ -11,3 +11,16 @@ describe Bunny::Session do
11
11
  c.should be_closed
12
12
  end
13
13
  end
14
+
15
+
16
+ describe Bunny::Session, "in a single threaded mode" do
17
+ it "can be closed" do
18
+ c = Bunny.new(:automatically_recover => false, :threaded => false)
19
+ c.start
20
+ ch = c.create_channel
21
+
22
+ c.should be_connected
23
+ c.stop
24
+ c.should be_closed
25
+ end
26
+ end
@@ -80,4 +80,49 @@ describe Bunny::Channel do
80
80
  ch.close
81
81
  end
82
82
  end
83
+
84
+
85
+
86
+ context "with consumer re-registration" do
87
+ class ExampleConsumerThatReregisters < Bunny::Consumer
88
+ def handle_cancellation(_)
89
+ @queue = @channel.queue("basic.consume.after_cancellation", :auto_delete => true)
90
+ @channel.basic_consume_with(self)
91
+ end
92
+ end
93
+
94
+ let(:queue_name) { "basic.consume#{rand}" }
95
+
96
+ it "works correctly" do
97
+ consumer = nil
98
+ xs = []
99
+
100
+ ch = connection.create_channel
101
+ t = Thread.new do
102
+ ch2 = connection.create_channel
103
+ q = ch2.queue(queue_name, :auto_delete => true)
104
+
105
+ consumer = ExampleConsumerThatReregisters.new(ch2, q, "")
106
+ consumer.on_delivery do |_, _, payload|
107
+ xs << payload
108
+ end
109
+ q.subscribe_with(consumer)
110
+ end
111
+ t.abort_on_exception = true
112
+
113
+ sleep 0.5
114
+ x = ch.default_exchange
115
+ x.publish("abc", :routing_key => queue_name)
116
+
117
+ sleep 0.5
118
+ ch.queue(queue_name, :auto_delete => true).delete
119
+
120
+ x.publish("abc", :routing_key => queue_name)
121
+ sleep 0.5
122
+ q = ch.queue("basic.consume.after_cancellation", :auto_delete => true)
123
+ xs.should == ["abc"]
124
+
125
+ ch.close
126
+ end
127
+ end
83
128
  end
@@ -22,5 +22,19 @@ unless RUBY_ENGINE == "jruby" && !ENV["FORCE_JRUBY_RUN"]
22
22
  c.should be_closed
23
23
  end
24
24
  end
25
+
26
+ context "in the single threaded mode" do
27
+ n.times do |i|
28
+ it "can be closed (take #{i})" do
29
+ c = Bunny.new(:automatically_recover => false, :threaded => false)
30
+ c.start
31
+ ch = c.create_channel
32
+
33
+ c.should be_connected
34
+ c.stop
35
+ c.should be_closed
36
+ end
37
+ end
38
+ end
25
39
  end
26
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-08-07 00:00:00.000000000 Z
15
+ date: 2013-08-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -28,7 +28,8 @@ dependencies:
28
28
  - - '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: 1.6.0
31
- description: Easy to use, feature complete Ruby client for RabbitMQ 2.0.
31
+ description: Easy to use, feature complete Ruby client for RabbitMQ 2.0 and later
32
+ versions.
32
33
  email:
33
34
  - celldee@gmail.com
34
35
  - eric@5stops.com