bunny 0.10.8 → 1.0.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/ChangeLog.md +1 -152
- data/Gemfile +1 -1
- data/README.md +5 -5
- data/bunny.gemspec +1 -1
- data/lib/bunny.rb +14 -2
- data/lib/bunny/channel.rb +94 -158
- data/lib/bunny/channel_id_allocator.rb +1 -2
- data/lib/bunny/concurrent/condition.rb +1 -2
- data/lib/bunny/concurrent/continuation_queue.rb +1 -1
- data/lib/bunny/consumer.rb +0 -13
- data/lib/bunny/consumer_work_pool.rb +2 -5
- data/lib/bunny/delivery_info.rb +1 -3
- data/lib/bunny/exceptions.rb +1 -4
- data/lib/bunny/heartbeat_sender.rb +1 -1
- data/lib/bunny/reader_loop.rb +3 -23
- data/lib/bunny/session.rb +19 -103
- data/lib/bunny/socket.rb +1 -1
- data/lib/bunny/transport.rb +7 -31
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_ack_spec.rb +19 -34
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_consume_spec.rb +2 -63
- data/spec/higher_level_api/integration/basic_get_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_nack_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_publish_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_qos_spec.rb +8 -5
- data/spec/higher_level_api/integration/basic_reject_spec.rb +17 -16
- data/spec/higher_level_api/integration/basic_return_spec.rb +1 -1
- data/spec/higher_level_api/integration/channel_close_spec.rb +10 -6
- data/spec/higher_level_api/integration/channel_flow_spec.rb +9 -6
- data/spec/higher_level_api/integration/channel_open_spec.rb +20 -11
- data/spec/higher_level_api/integration/confirm_select_spec.rb +1 -1
- data/spec/higher_level_api/integration/connection_spec.rb +1 -1
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +1 -1
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +1 -46
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +1 -1
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +1 -1
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +1 -1
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_declare_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_delete_spec.rb +2 -2
- data/spec/higher_level_api/integration/queue_purge_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +2 -2
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +1 -1
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +2 -2
- data/spec/higher_level_api/integration/tls_connection_spec.rb +2 -86
- 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/unit/concurrent/condition_spec.rb +46 -53
- metadata +5 -25
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/lib/amq/protocol/extensions.rb +0 -16
- data/lib/bunny/concurrent/atomic_fixnum.rb +0 -74
- data/lib/bunny/concurrent/synchronized_sorted_set.rb +0 -56
- data/lib/bunny/timeout.rb +0 -18
- data/lib/bunny/versioned_delivery_tag.rb +0 -28
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
- data/spec/issues/issue141_spec.rb +0 -44
- data/spec/stress/connection_open_close_spec.rb +0 -40
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
data/lib/bunny/version.rb
CHANGED
@@ -7,65 +7,50 @@ describe Bunny::Channel, "#ack" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close if connection.open?
|
12
12
|
end
|
13
13
|
|
14
|
+
subject do
|
15
|
+
connection.create_channel
|
16
|
+
end
|
17
|
+
|
14
18
|
context "with a valid (known) delivery tag" do
|
15
19
|
it "acknowleges a message" do
|
16
|
-
|
17
|
-
|
18
|
-
x = ch.default_exchange
|
20
|
+
q = subject.queue("bunny.basic.ack.manual-acks", :exclusive => true)
|
21
|
+
x = subject.default_exchange
|
19
22
|
|
20
23
|
x.publish("bunneth", :routing_key => q.name)
|
21
|
-
sleep
|
24
|
+
sleep(0.25)
|
22
25
|
q.message_count.should == 1
|
23
26
|
delivery_details, properties, content = q.pop(:ack => true)
|
24
27
|
|
25
|
-
|
28
|
+
subject.ack(delivery_details.delivery_tag, true)
|
29
|
+
sleep(0.25)
|
26
30
|
q.message_count.should == 0
|
27
31
|
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
context "with a valid (known) delivery tag and automatic ack mode" do
|
34
|
-
it "results in a channel exception" do
|
35
|
-
ch = connection.create_channel
|
36
|
-
q = ch.queue("bunny.basic.ack.manual-acks", :exclusive => true)
|
37
|
-
x = ch.default_exchange
|
38
|
-
|
39
|
-
q.subscribe(:manual_ack => false) do |delivery_info, properties, payload|
|
40
|
-
ch.ack(delivery_info.delivery_tag, false)
|
41
|
-
end
|
42
|
-
|
43
|
-
x.publish("bunneth", :routing_key => q.name)
|
44
|
-
sleep 0.5
|
45
|
-
lambda do
|
46
|
-
q.message_count
|
47
|
-
end.should raise_error(Bunny::ChannelAlreadyClosed)
|
32
|
+
subject.close
|
48
33
|
end
|
49
34
|
end
|
50
35
|
|
51
36
|
context "with an invalid (random) delivery tag" do
|
52
37
|
it "causes a channel-level error" do
|
53
|
-
|
54
|
-
|
55
|
-
x = ch.default_exchange
|
38
|
+
q = subject.queue("bunny.basic.ack.unknown-delivery-tag", :exclusive => true)
|
39
|
+
x = subject.default_exchange
|
56
40
|
|
57
41
|
x.publish("bunneth", :routing_key => q.name)
|
58
|
-
sleep
|
42
|
+
sleep(0.25)
|
59
43
|
q.message_count.should == 1
|
60
44
|
_, _, content = q.pop(:ack => true)
|
61
45
|
|
62
|
-
|
46
|
+
subject.on_error do |ch, channel_close|
|
63
47
|
@channel_close = channel_close
|
64
48
|
end
|
65
|
-
|
66
|
-
|
49
|
+
subject.ack(82, true)
|
50
|
+
|
51
|
+
sleep 0.5
|
67
52
|
|
68
|
-
@channel_close.
|
53
|
+
@channel_close.reply_text.should == "PRECONDITION_FAILED - unknown delivery tag 82"
|
69
54
|
end
|
70
55
|
end
|
71
56
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "set"
|
3
2
|
|
4
3
|
describe Bunny::Queue, "#subscribe" do
|
5
4
|
let(:connection) do
|
@@ -8,7 +7,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
8
7
|
c
|
9
8
|
end
|
10
9
|
|
11
|
-
after :
|
10
|
+
after :all do
|
12
11
|
connection.close if connection.open?
|
13
12
|
end
|
14
13
|
|
@@ -42,66 +41,6 @@ describe Bunny::Queue, "#subscribe" do
|
|
42
41
|
|
43
42
|
ch.close
|
44
43
|
end
|
45
|
-
|
46
|
-
context "with a single consumer" do
|
47
|
-
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
48
|
-
|
49
|
-
it "provides delivery tag access" do
|
50
|
-
delivery_tags = SortedSet.new
|
51
|
-
|
52
|
-
cch = connection.create_channel
|
53
|
-
q = cch.queue(queue_name, :auto_delete => true, :durable => false)
|
54
|
-
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
55
|
-
delivery_tags << delivery_info.delivery_tag
|
56
|
-
end
|
57
|
-
sleep 0.5
|
58
|
-
|
59
|
-
ch = connection.create_channel
|
60
|
-
x = ch.default_exchange
|
61
|
-
100.times do
|
62
|
-
x.publish("hello", :routing_key => queue_name)
|
63
|
-
end
|
64
|
-
|
65
|
-
sleep 1.0
|
66
|
-
delivery_tags.should == SortedSet.new(Range.new(1, 100).to_a)
|
67
|
-
|
68
|
-
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0
|
69
|
-
|
70
|
-
ch.close
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
context "with multiple consumers on the same channel" do
|
76
|
-
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
77
|
-
|
78
|
-
it "provides delivery tag access" do
|
79
|
-
delivery_tags = SortedSet.new
|
80
|
-
|
81
|
-
cch = connection.create_channel
|
82
|
-
q = cch.queue(queue_name, :auto_delete => true, :durable => false)
|
83
|
-
|
84
|
-
7.times do
|
85
|
-
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
86
|
-
delivery_tags << delivery_info.delivery_tag
|
87
|
-
end
|
88
|
-
end
|
89
|
-
sleep 1.0
|
90
|
-
|
91
|
-
ch = connection.create_channel
|
92
|
-
x = ch.default_exchange
|
93
|
-
100.times do
|
94
|
-
x.publish("hello", :routing_key => queue_name)
|
95
|
-
end
|
96
|
-
|
97
|
-
sleep 1.5
|
98
|
-
delivery_tags.should == SortedSet.new(Range.new(1, 100).to_a)
|
99
|
-
|
100
|
-
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0
|
101
|
-
|
102
|
-
ch.close
|
103
|
-
end
|
104
|
-
end
|
105
44
|
end
|
106
45
|
|
107
46
|
context "with manual acknowledgement mode" do
|
@@ -138,7 +77,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
138
77
|
end
|
139
78
|
end
|
140
79
|
|
141
|
-
|
80
|
+
20.times do |i|
|
142
81
|
context "with a queue that already has messages (take #{i})" do
|
143
82
|
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
144
83
|
|
@@ -7,22 +7,25 @@ describe Bunny::Channel, "#prefetch" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
14
|
+
|
15
|
+
subject do
|
16
|
+
connection.create_channel
|
17
|
+
end
|
18
|
+
|
14
19
|
context "with a positive integer" do
|
15
20
|
it "sets that prefetch level via basic.qos" do
|
16
|
-
|
17
|
-
ch.prefetch(10).should be_instance_of(AMQ::Protocol::Basic::QosOk)
|
21
|
+
subject.prefetch(10).should be_instance_of(AMQ::Protocol::Basic::QosOk)
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
context "with a negative integer" do
|
22
26
|
it "raises an ArgumentError" do
|
23
|
-
ch = connection.create_channel
|
24
27
|
expect {
|
25
|
-
|
28
|
+
subject.prefetch(-2)
|
26
29
|
}.to raise_error(ArgumentError)
|
27
30
|
end
|
28
31
|
end
|
@@ -7,64 +7,65 @@ describe Bunny::Channel, "#reject" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close if connection.open?
|
12
12
|
end
|
13
13
|
|
14
|
+
subject do
|
15
|
+
connection.create_channel
|
16
|
+
end
|
17
|
+
|
14
18
|
context "with requeue = true" do
|
15
19
|
it "requeues a message" do
|
16
|
-
|
17
|
-
|
18
|
-
x = ch.default_exchange
|
20
|
+
q = subject.queue("bunny.basic.reject.manual-acks", :exclusive => true)
|
21
|
+
x = subject.default_exchange
|
19
22
|
|
20
23
|
x.publish("bunneth", :routing_key => q.name)
|
21
24
|
sleep(0.5)
|
22
25
|
q.message_count.should == 1
|
23
26
|
delivery_info, _, _ = q.pop(:ack => true)
|
24
27
|
|
25
|
-
|
28
|
+
subject.reject(delivery_info.delivery_tag, true)
|
26
29
|
sleep(0.5)
|
27
30
|
q.message_count.should == 1
|
28
31
|
|
29
|
-
|
32
|
+
subject.close
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
context "with requeue = false" do
|
34
37
|
it "rejects a message" do
|
35
|
-
|
36
|
-
|
37
|
-
x = ch.default_exchange
|
38
|
+
q = subject.queue("bunny.basic.reject.with-requeue-false", :exclusive => true)
|
39
|
+
x = subject.default_exchange
|
38
40
|
|
39
41
|
x.publish("bunneth", :routing_key => q.name)
|
40
42
|
sleep(0.5)
|
41
43
|
q.message_count.should == 1
|
42
44
|
delivery_info, _, _ = q.pop(:ack => true)
|
43
45
|
|
44
|
-
|
46
|
+
subject.reject(delivery_info.delivery_tag, false)
|
45
47
|
sleep(0.5)
|
46
48
|
q.message_count.should == 0
|
47
49
|
|
48
|
-
|
50
|
+
subject.close
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
|
53
55
|
context "with an invalid (random) delivery tag" do
|
54
56
|
it "causes a channel-level error" do
|
55
|
-
|
56
|
-
|
57
|
-
x = ch.default_exchange
|
57
|
+
q = subject.queue("bunny.basic.reject.unknown-delivery-tag", :exclusive => true)
|
58
|
+
x = subject.default_exchange
|
58
59
|
|
59
60
|
x.publish("bunneth", :routing_key => q.name)
|
60
61
|
sleep(0.25)
|
61
62
|
q.message_count.should == 1
|
62
63
|
_, _, content = q.pop(:ack => true)
|
63
64
|
|
64
|
-
|
65
|
+
subject.on_error do |ch, channel_close|
|
65
66
|
@channel_close = channel_close
|
66
67
|
end
|
67
|
-
|
68
|
+
subject.reject(82, true)
|
68
69
|
|
69
70
|
sleep 0.5
|
70
71
|
|
@@ -7,17 +7,21 @@ describe Bunny::Channel, "when closed" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
14
|
+
|
15
|
+
subject do
|
16
|
+
connection.create_channel
|
17
|
+
end
|
18
|
+
|
14
19
|
it "releases the id" do
|
15
|
-
|
16
|
-
n = ch.number
|
20
|
+
n = subject.number
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
subject.should be_open
|
23
|
+
subject.close
|
24
|
+
subject.should be_closed
|
21
25
|
|
22
26
|
# a new channel with the same id can be created
|
23
27
|
connection.create_channel(n)
|
@@ -7,15 +7,18 @@ describe Bunny::Channel, "#flow" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
14
|
-
it "is supported" do
|
15
|
-
ch = connection.create_channel
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
subject do
|
16
|
+
connection.create_channel
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is supported" do
|
20
|
+
subject.flow(true).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
21
|
+
subject.flow(false).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
22
|
+
subject.flow(true).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
20
23
|
end
|
21
24
|
end
|
@@ -7,42 +7,51 @@ describe Bunny::Channel, "when opened" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
14
14
|
context "without explicitly provided id" do
|
15
|
+
subject do
|
16
|
+
connection.create_channel
|
17
|
+
end
|
18
|
+
|
15
19
|
it "gets an allocated id and is successfully opened" do
|
16
20
|
connection.should be_connected
|
17
|
-
|
18
|
-
ch.should be_open
|
21
|
+
subject.should be_open
|
19
22
|
|
20
|
-
|
23
|
+
subject.id.should be > 0
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
27
|
|
25
28
|
context "with explicitly provided id" do
|
29
|
+
subject do
|
30
|
+
connection.create_channel(767)
|
31
|
+
end
|
32
|
+
|
26
33
|
it "uses that id and is successfully opened" do
|
27
|
-
ch = connection.create_channel(767)
|
28
34
|
connection.should be_connected
|
29
|
-
|
35
|
+
subject.should be_open
|
30
36
|
|
31
|
-
|
37
|
+
subject.id.should == 767
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
41
|
|
36
42
|
|
37
43
|
context "with explicitly provided id that is already taken" do
|
44
|
+
subject do
|
45
|
+
connection.create_channel(767)
|
46
|
+
end
|
47
|
+
|
38
48
|
it "reuses the channel that is already opened" do
|
39
|
-
ch = connection.create_channel(767)
|
40
49
|
connection.should be_connected
|
41
|
-
|
50
|
+
subject.should be_open
|
42
51
|
|
43
|
-
|
52
|
+
subject.id.should == 767
|
44
53
|
|
45
|
-
connection.create_channel(767).should ==
|
54
|
+
connection.create_channel(767).should == subject
|
46
55
|
end
|
47
56
|
end
|
48
57
|
end
|