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 +4 -4
- data/ChangeLog.md +23 -0
- data/bunny.gemspec +1 -1
- data/lib/bunny/channel.rb +16 -7
- data/lib/bunny/reader_loop.rb +6 -4
- data/lib/bunny/session.rb +16 -14
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/connection_stop_spec.rb +13 -0
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +45 -0
- data/spec/stress/connection_open_close_spec.rb +14 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f79488e6b65537ea12c2a0675e23f22b954f04
|
4
|
+
data.tar.gz: ececfcb8dc3374af17d6a2e9265a6b4a1fa02d8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39577f8e482fc0fdbd727077c82747a262f97967c3e8e8027a410a2bc08cf41cf45edd46f383c1128f308c40c4602ecfaf64d56323cba3d8528582706f3ee292
|
7
|
+
data.tar.gz: c22ca1d276aaa7d9dd992040366dcb3d27179dadc10c7204de1e2e75a8f641de955755a0118feb874507e9c3ee7a883a361787251fdea8834c59647cb7fc4719
|
data/ChangeLog.md
CHANGED
@@ -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
|
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."
|
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.
|
data/lib/bunny/channel.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
1859
|
+
# if a fixnum was passed, execute unconditionally. MK.
|
1851
1860
|
when Fixnum then
|
1852
1861
|
block.call
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
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
|
data/lib/bunny/reader_loop.rb
CHANGED
@@ -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
|
103
|
-
|
102
|
+
if @thread
|
103
|
+
@thread.kill
|
104
|
+
@thread.join
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
def log_exception(e)
|
data/lib/bunny/session.rb
CHANGED
@@ -226,7 +226,7 @@ module Bunny
|
|
226
226
|
self.open_connection
|
227
227
|
|
228
228
|
@reader_loop = nil
|
229
|
-
self.start_reader_loop if
|
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
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
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
|
-
|
644
|
+
# single threaded mode, nothing to do. MK.
|
643
645
|
end
|
644
646
|
end
|
645
647
|
|
data/lib/bunny/version.rb
CHANGED
@@ -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.
|
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-
|
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
|