bunny 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +46 -2
- data/Gemfile +1 -1
- data/lib/bunny/get_response.rb +83 -0
- data/lib/bunny/queue.rb +17 -20
- data/lib/bunny/session.rb +5 -1
- data/lib/bunny/transport.rb +3 -1
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_get_spec.rb +13 -5
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +48 -2
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +22 -0
- data/spec/stress/connection_open_close_spec.rb +0 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 972f0f0055bbc831144da54e6805c4d5f5e2262c
|
4
|
+
data.tar.gz: ad2f3539fb6946771238e6451b17d33cfdba692b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad93a02f5623437589eb2027259de36a2269df8ab06d251b00e6b28b265f8f562068a1c7e473b2513eff18bdde77902b46a24c114a9a1c9dbe29426c93f67085
|
7
|
+
data.tar.gz: da94e1d8349674cf2819678f2fb18a1fd911017fb7c99104d64d755c9d7f9622068db60a5502411c6442d04fe341372d09d31c6e5885c0cda18293ea04db3e81
|
data/ChangeLog.md
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
-
## Changes between Bunny 1.2.
|
1
|
+
## Changes between Bunny 1.2.0 and 1.3.0
|
2
|
+
|
3
|
+
### TLS Can Be Explicitly Disabled
|
4
|
+
|
5
|
+
TLS now can be explicitly disabled even when connecting (without TLS)
|
6
|
+
to the default RabbitMQ TLS/amqps port (5671):
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
conn = Bunny.new(:port => 5671, :tls => false)
|
10
|
+
```
|
11
|
+
|
12
|
+
Contributed by Muhan Zou.
|
13
|
+
|
14
|
+
|
15
|
+
### Single Threaded Connections Raise Shutdown Exceptions
|
16
|
+
|
17
|
+
Single threaded Bunny connections will now raise exceptions
|
18
|
+
that occur during shutdown as is (instead of trying to shut down
|
19
|
+
I/O loop which only threaded ones have).
|
20
|
+
|
21
|
+
Contributed by Carl Hörberg.
|
22
|
+
|
2
23
|
|
3
24
|
### Synchronization Improvements for Session#close
|
4
25
|
|
@@ -6,7 +27,29 @@
|
|
6
27
|
eliminating a few race condition scenarios with I/O reader thread.
|
7
28
|
|
8
29
|
|
9
|
-
|
30
|
+
### Bunny::Exchange.default Fix
|
31
|
+
|
32
|
+
`Bunny::Exchange.default` no longer raises an exception.
|
33
|
+
|
34
|
+
Note that it is a legacy compatibility method. Please use
|
35
|
+
`Bunny::Channel#default_exchange` instead.
|
36
|
+
|
37
|
+
Contributed by Justin Litchfield.
|
38
|
+
|
39
|
+
GH issue [#211](https://github.com/ruby-amqp/bunny/pull/211).
|
40
|
+
|
41
|
+
### Bunny::Queue#pop_as_hash Removed
|
42
|
+
|
43
|
+
`Bunny::Queue#pop_as_hash`, which was added to ease migration
|
44
|
+
to Bunny 0.9, was removed.
|
45
|
+
|
46
|
+
### Bunny::Queue#pop Wraps Metadata
|
47
|
+
|
48
|
+
`Bunny::Queue#pop` now wraps `basic.get-ok` and message properties
|
49
|
+
into `Bunny::GetResponse` and `Bunny::MessageProperties`, just like
|
50
|
+
`basic.consume` deliveries.
|
51
|
+
|
52
|
+
GH issue: [#212](https://github.com/ruby-amqp/bunny/issues/212).
|
10
53
|
|
11
54
|
### Better Synchronization for Publisher Confirms
|
12
55
|
|
@@ -23,6 +66,7 @@ on a recovered connection (in addition to the channels
|
|
23
66
|
it already had).
|
24
67
|
|
25
68
|
|
69
|
+
|
26
70
|
## Changes between Bunny 1.1.0 and 1.2.0
|
27
71
|
|
28
72
|
### :key Supported in Bunny::Channel#queue_bind
|
data/Gemfile
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
require "bunny/versioned_delivery_tag"
|
2
|
+
|
3
|
+
module Bunny
|
4
|
+
# Wraps {AMQ::Protocol::Basic::GetOk} to
|
5
|
+
# provide access to the delivery properties as immutable hash as
|
6
|
+
# well as methods.
|
7
|
+
class GetResponse
|
8
|
+
|
9
|
+
#
|
10
|
+
# Behaviors
|
11
|
+
#
|
12
|
+
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
#
|
16
|
+
# API
|
17
|
+
#
|
18
|
+
|
19
|
+
# @return [Bunny::Channel] Channel this basic.get-ok response is on
|
20
|
+
attr_reader :channel
|
21
|
+
|
22
|
+
# @private
|
23
|
+
def initialize(get_ok, consumer, channel)
|
24
|
+
@get_ok = get_ok
|
25
|
+
@hash = {
|
26
|
+
:delivery_tag => @get_ok.delivery_tag,
|
27
|
+
:redelivered => @get_ok.redelivered,
|
28
|
+
:exchange => @get_ok.exchange,
|
29
|
+
:routing_key => @get_ok.routing_key,
|
30
|
+
:channel => channel
|
31
|
+
}
|
32
|
+
@channel = channel
|
33
|
+
end
|
34
|
+
|
35
|
+
# Iterates over the delivery properties
|
36
|
+
# @see Enumerable#each
|
37
|
+
def each(*args, &block)
|
38
|
+
@hash.each(*args, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Accesses delivery properties by key
|
42
|
+
# @see Hash#[]
|
43
|
+
def [](k)
|
44
|
+
@hash[k]
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Hash] Hash representation of this delivery info
|
48
|
+
def to_hash
|
49
|
+
@hash
|
50
|
+
end
|
51
|
+
|
52
|
+
# @private
|
53
|
+
def to_s
|
54
|
+
to_hash.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
# @private
|
58
|
+
def inspect
|
59
|
+
to_hash.inspect
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String] Delivery identifier that is used to acknowledge, reject and nack deliveries
|
63
|
+
def delivery_tag
|
64
|
+
@get_ok.delivery_tag
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Boolean] true if this delivery is a redelivery (the message was requeued at least once)
|
68
|
+
def redelivered
|
69
|
+
@get_ok.redelivered
|
70
|
+
end
|
71
|
+
alias redelivered? redelivered
|
72
|
+
|
73
|
+
# @return [String] Name of the exchange this message was published to
|
74
|
+
def exchange
|
75
|
+
@get_ok.exchange
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String] Routing key this message was published with
|
79
|
+
def routing_key
|
80
|
+
@get_ok.routing_key
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/bunny/queue.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "bunny/compatibility"
|
2
|
+
require "bunny/get_response"
|
2
3
|
|
3
4
|
module Bunny
|
4
5
|
# Represents AMQP 0.9.1 queue.
|
@@ -229,33 +230,29 @@ module Bunny
|
|
229
230
|
# puts "This is the message: " + payload + "\n\n"
|
230
231
|
# conn.close
|
231
232
|
def pop(opts = {:ack => false}, &block)
|
232
|
-
|
233
|
+
get_response, properties, content = @channel.basic_get(@name, opts)
|
233
234
|
|
234
235
|
if block
|
235
|
-
|
236
|
+
if properties
|
237
|
+
di = GetResponse.new(get_response, properties, @channel)
|
238
|
+
mp = MessageProperties.new(properties)
|
239
|
+
|
240
|
+
block.call(di, mp, content)
|
241
|
+
else
|
242
|
+
block.call(nil, nil, nil)
|
243
|
+
end
|
236
244
|
else
|
237
|
-
|
245
|
+
if properties
|
246
|
+
di = GetResponse.new(get_response, properties, @channel)
|
247
|
+
mp = MessageProperties.new(properties)
|
248
|
+
[di, mp, content]
|
249
|
+
else
|
250
|
+
[nil, nil, nil]
|
251
|
+
end
|
238
252
|
end
|
239
253
|
end
|
240
254
|
alias get pop
|
241
255
|
|
242
|
-
# Version of {Bunny::Queue#pop} that returns data in legacy format
|
243
|
-
# (as a hash).
|
244
|
-
# @return [Hash]
|
245
|
-
# @deprecated
|
246
|
-
def pop_as_hash(opts = {:ack => false}, &block)
|
247
|
-
delivery_info, properties, content = @channel.basic_get(@name, opts)
|
248
|
-
|
249
|
-
result = {:header => properties, :payload => content, :delivery_details => delivery_info}
|
250
|
-
|
251
|
-
if block
|
252
|
-
block.call(result)
|
253
|
-
else
|
254
|
-
result
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
|
259
256
|
# Publishes a message to the queue via default exchange. Takes the same arguments
|
260
257
|
# as {Bunny::Exchange#publish}
|
261
258
|
#
|
data/lib/bunny/session.rb
CHANGED
@@ -707,7 +707,11 @@ module Bunny
|
|
707
707
|
@continuations.push(method)
|
708
708
|
|
709
709
|
clean_up_on_shutdown
|
710
|
-
|
710
|
+
if threaded?
|
711
|
+
@origin_thread.terminate_with(@last_connection_error)
|
712
|
+
else
|
713
|
+
raise @last_connection_error
|
714
|
+
end
|
711
715
|
end
|
712
716
|
|
713
717
|
def clean_up_on_shutdown
|
data/lib/bunny/transport.rb
CHANGED
@@ -265,7 +265,9 @@ module Bunny
|
|
265
265
|
protected
|
266
266
|
|
267
267
|
def tls_enabled?(opts)
|
268
|
-
opts[:tls]
|
268
|
+
return opts[:tls] unless opts[:tls].nil?
|
269
|
+
return opts[:ssl] unless opts[:ssl].nil?
|
270
|
+
(opts[:port] == AMQ::Protocol::TLS_PORT) || false
|
269
271
|
end
|
270
272
|
|
271
273
|
def tls_certificate_path_from(opts)
|
data/lib/bunny/version.rb
CHANGED
@@ -19,11 +19,17 @@ describe Bunny::Queue, "#pop" do
|
|
19
19
|
q = ch.queue("", :exclusive => true)
|
20
20
|
x = ch.default_exchange
|
21
21
|
|
22
|
-
|
22
|
+
msg = "xyzzy"
|
23
|
+
x.publish(msg, :routing_key => q.name)
|
23
24
|
|
24
25
|
sleep(0.5)
|
25
|
-
|
26
|
-
|
26
|
+
get_ok, properties, content = q.pop
|
27
|
+
expect(get_ok).to be_kind_of(Bunny::GetResponse)
|
28
|
+
expect(properties).to be_kind_of(Bunny::MessageProperties)
|
29
|
+
expect(properties.content_type).to eq("application/octet-stream")
|
30
|
+
expect(get_ok.routing_key).to eq(q.name)
|
31
|
+
expect(get_ok.delivery_tag).to be_kind_of(Bunny::VersionedDeliveryTag)
|
32
|
+
expect(content).to eq(msg)
|
27
33
|
q.message_count.should == 0
|
28
34
|
|
29
35
|
ch.close
|
@@ -38,8 +44,10 @@ describe Bunny::Queue, "#pop" do
|
|
38
44
|
q = ch.queue("", :exclusive => true)
|
39
45
|
q.purge
|
40
46
|
|
41
|
-
|
42
|
-
|
47
|
+
get_empty, properties, content = q.pop
|
48
|
+
expect(get_empty).to eq(nil)
|
49
|
+
expect(properties).to eq(nil)
|
50
|
+
expect(content).to eq(nil)
|
43
51
|
q.message_count.should == 0
|
44
52
|
|
45
53
|
ch.close
|
@@ -13,7 +13,7 @@ unless ENV["CI"]
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def wait_for_recovery
|
16
|
-
sleep
|
16
|
+
sleep 1.5
|
17
17
|
end
|
18
18
|
|
19
19
|
def with_open(c = Bunny.new(:network_recovery_interval => 0.2, :recover_from_connection_close => true), &block)
|
@@ -209,7 +209,7 @@ unless ENV["CI"]
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
it "recovers
|
212
|
+
it "recovers consumers" do
|
213
213
|
with_open do |c|
|
214
214
|
delivered = false
|
215
215
|
|
@@ -230,5 +230,51 @@ unless ENV["CI"]
|
|
230
230
|
expect(delivered).to be_true
|
231
231
|
end
|
232
232
|
end
|
233
|
+
|
234
|
+
it "recovers all consumers" do
|
235
|
+
n = 1024
|
236
|
+
|
237
|
+
with_open do |c|
|
238
|
+
ch = c.create_channel
|
239
|
+
q = ch.queue("", :exclusive => true)
|
240
|
+
n.times do
|
241
|
+
q.subscribe do |_, _, _|
|
242
|
+
delivered = true
|
243
|
+
end
|
244
|
+
end
|
245
|
+
close_all_connections!
|
246
|
+
sleep 0.1
|
247
|
+
c.should_not be_open
|
248
|
+
|
249
|
+
wait_for_recovery
|
250
|
+
ch.should be_open
|
251
|
+
|
252
|
+
q.consumer_count.should == n
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
it "recovers all queues" do
|
257
|
+
n = 256
|
258
|
+
|
259
|
+
qs = []
|
260
|
+
|
261
|
+
with_open do |c|
|
262
|
+
ch = c.create_channel
|
263
|
+
|
264
|
+
n.times do
|
265
|
+
qs << ch.queue("", :exclusive => true)
|
266
|
+
end
|
267
|
+
close_all_connections!
|
268
|
+
sleep 0.1
|
269
|
+
c.should_not be_open
|
270
|
+
|
271
|
+
wait_for_recovery
|
272
|
+
ch.should be_open
|
273
|
+
|
274
|
+
qs.each do |q|
|
275
|
+
ch.queue_declare(q.name, :passive => true)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
233
279
|
end
|
234
280
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require "spec_helper"
|
2
3
|
|
3
4
|
unless ENV["CI"]
|
@@ -37,6 +38,27 @@ unless ENV["CI"]
|
|
37
38
|
end
|
38
39
|
|
39
40
|
|
41
|
+
context "with payload of several MBs of non-ASCII characters" do
|
42
|
+
it "successfully frames the message" do
|
43
|
+
ch = connection.create_channel
|
44
|
+
|
45
|
+
q = ch.queue("", :exclusive => true)
|
46
|
+
x = ch.default_exchange
|
47
|
+
|
48
|
+
as = "кириллца, йо" * (1024 * 1024)
|
49
|
+
x.publish(as, :routing_key => q.name, :persistent => true)
|
50
|
+
|
51
|
+
sleep(1)
|
52
|
+
q.message_count.should == 1
|
53
|
+
|
54
|
+
_, _, payload = q.pop
|
55
|
+
payload.bytesize.should == as.bytesize
|
56
|
+
|
57
|
+
ch.close
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
40
62
|
|
41
63
|
context "with empty message body" do
|
42
64
|
it "successfully publishes the message" do
|
@@ -23,24 +23,6 @@ unless defined?(JRUBY_VERSION) && !ENV["FORCE_JRUBY_RUN"]
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
n.times do |i|
|
27
|
-
it "can be closed in the Hello, World example (take #{i})" do
|
28
|
-
c = Bunny.new(:automatically_recover => false)
|
29
|
-
c.start
|
30
|
-
ch = c.create_channel
|
31
|
-
x = ch.default_exchange
|
32
|
-
q = ch.queue("", :exclusive => true)
|
33
|
-
q.subscribe do |delivery_info, properties, payload|
|
34
|
-
# no-op
|
35
|
-
end
|
36
|
-
20.times { x.publish("hello", :routing_key => q.name) }
|
37
|
-
|
38
|
-
c.should be_connected
|
39
|
-
c.stop
|
40
|
-
c.should be_closed
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
26
|
n.times do |i|
|
45
27
|
it "can be closed (automatic recovery enabled, take #{i})" do
|
46
28
|
c = Bunny.new(:automatically_recover => true)
|
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: 1.
|
4
|
+
version: 1.3.0
|
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: 2014-
|
15
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: amq-protocol
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/bunny/exceptions.rb
|
119
119
|
- lib/bunny/exchange.rb
|
120
120
|
- lib/bunny/framing.rb
|
121
|
+
- lib/bunny/get_response.rb
|
121
122
|
- lib/bunny/heartbeat_sender.rb
|
122
123
|
- lib/bunny/jruby/socket.rb
|
123
124
|
- lib/bunny/jruby/ssl_socket.rb
|
@@ -305,4 +306,3 @@ test_files:
|
|
305
306
|
- spec/unit/concurrent/synchronized_sorted_set_spec.rb
|
306
307
|
- spec/unit/system_timer_spec.rb
|
307
308
|
- spec/unit/version_delivery_tag_spec.rb
|
308
|
-
has_rdoc: true
|