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
@@ -7,7 +7,7 @@ describe Bunny::Channel 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
|
|
@@ -80,49 +80,4 @@ 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
|
128
83
|
end
|
@@ -7,7 +7,7 @@ describe Bunny::Queue, "#delete" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
@@ -22,7 +22,7 @@ describe Bunny::Queue, "#delete" do
|
|
22
22
|
expect {
|
23
23
|
q.delete
|
24
24
|
}.to raise_error(Bunny::NotFound)
|
25
|
-
|
25
|
+
|
26
26
|
ch.queues.size.should == 0
|
27
27
|
end
|
28
28
|
end
|
@@ -7,7 +7,7 @@ describe Bunny::Queue, "bound to an exchange" do
|
|
7
7
|
c
|
8
8
|
end
|
9
9
|
|
10
|
-
after :
|
10
|
+
after :all do
|
11
11
|
connection.close
|
12
12
|
end
|
13
13
|
|
@@ -37,7 +37,7 @@ describe Bunny::Queue, "NOT bound to an exchange" do
|
|
37
37
|
c
|
38
38
|
end
|
39
39
|
|
40
|
-
after :
|
40
|
+
after :all do
|
41
41
|
connection.close
|
42
42
|
end
|
43
43
|
|
@@ -7,7 +7,7 @@ describe "Sender-selected distribution" 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
|
|
@@ -23,7 +23,7 @@ describe "Sender-selected distribution" do
|
|
23
23
|
n.times do |i|
|
24
24
|
x.publish("Message #{i}", :routing_key => "one", :headers => {"CC" => ["two", "three"]})
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
sleep 0.5
|
28
28
|
|
29
29
|
q1.message_count.should == n
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
unless ENV["CI"]
|
5
|
-
describe "TLS connection to RabbitMQ
|
5
|
+
describe "TLS connection to RabbitMQ" do
|
6
6
|
let(:connection) do
|
7
7
|
c = Bunny.new(:user => "bunny_gem",
|
8
8
|
:password => "bunny_password",
|
@@ -15,7 +15,7 @@ unless ENV["CI"]
|
|
15
15
|
c
|
16
16
|
end
|
17
17
|
|
18
|
-
after :
|
18
|
+
after :all do
|
19
19
|
connection.close
|
20
20
|
end
|
21
21
|
|
@@ -44,88 +44,4 @@ unless ENV["CI"]
|
|
44
44
|
ch.close
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
|
49
|
-
describe "TLS connection to RabbitMQ without client certificates" do
|
50
|
-
let(:connection) do
|
51
|
-
c = Bunny.new(:user => "bunny_gem",
|
52
|
-
:password => "bunny_password",
|
53
|
-
:vhost => "bunny_testbed",
|
54
|
-
:tls => true,
|
55
|
-
:tls_ca_certificates => ["./spec/tls/cacert.pem"])
|
56
|
-
c.start
|
57
|
-
c
|
58
|
-
end
|
59
|
-
|
60
|
-
after :each do
|
61
|
-
connection.close
|
62
|
-
end
|
63
|
-
|
64
|
-
it "provides the same API as a regular connection" do
|
65
|
-
ch = connection.create_channel
|
66
|
-
|
67
|
-
q = ch.queue("", :exclusive => true)
|
68
|
-
x = ch.default_exchange
|
69
|
-
|
70
|
-
x.publish("xyzzy", :routing_key => q.name).
|
71
|
-
publish("xyzzy", :routing_key => q.name).
|
72
|
-
publish("xyzzy", :routing_key => q.name).
|
73
|
-
publish("xyzzy", :routing_key => q.name)
|
74
|
-
|
75
|
-
sleep 0.5
|
76
|
-
q.message_count.should == 4
|
77
|
-
|
78
|
-
i = 0
|
79
|
-
q.subscribe do |delivery_info, _, payload|
|
80
|
-
i += 1
|
81
|
-
end
|
82
|
-
sleep 1.0
|
83
|
-
i.should == 4
|
84
|
-
q.message_count.should == 0
|
85
|
-
|
86
|
-
ch.close
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
describe "TLS connection to RabbitMQ with a connection string" do
|
92
|
-
let(:connection) do
|
93
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@127.0.0.1/bunny_testbed",
|
94
|
-
:tls_cert => "spec/tls/client_cert.pem",
|
95
|
-
:tls_key => "spec/tls/client_key.pem",
|
96
|
-
:tls_ca_certificates => ["./spec/tls/cacert.pem"])
|
97
|
-
c.start
|
98
|
-
c
|
99
|
-
end
|
100
|
-
|
101
|
-
after :each do
|
102
|
-
connection.close
|
103
|
-
end
|
104
|
-
|
105
|
-
it "provides the same API as a regular connection" do
|
106
|
-
connection.should be_tls
|
107
|
-
ch = connection.create_channel
|
108
|
-
|
109
|
-
q = ch.queue("", :exclusive => true)
|
110
|
-
x = ch.default_exchange
|
111
|
-
|
112
|
-
x.publish("xyzzy", :routing_key => q.name).
|
113
|
-
publish("xyzzy", :routing_key => q.name).
|
114
|
-
publish("xyzzy", :routing_key => q.name).
|
115
|
-
publish("xyzzy", :routing_key => q.name)
|
116
|
-
|
117
|
-
sleep 0.5
|
118
|
-
q.message_count.should == 4
|
119
|
-
|
120
|
-
i = 0
|
121
|
-
q.subscribe do |delivery_info, _, payload|
|
122
|
-
i += 1
|
123
|
-
end
|
124
|
-
sleep 1.0
|
125
|
-
i.should == 4
|
126
|
-
q.message_count.should == 0
|
127
|
-
|
128
|
-
ch.close
|
129
|
-
end
|
130
|
-
end
|
131
47
|
end
|
@@ -2,80 +2,73 @@ require "spec_helper"
|
|
2
2
|
require "bunny/concurrent/condition"
|
3
3
|
|
4
4
|
describe Bunny::Concurrent::Condition do
|
5
|
-
|
6
5
|
describe "#wait" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
xs = []
|
6
|
+
it "blocks current thread until notified" do
|
7
|
+
condition = described_class.new
|
8
|
+
xs = []
|
11
9
|
|
12
|
-
|
13
|
-
|
10
|
+
t = Thread.new do
|
11
|
+
xs << :notified
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
t.abort_on_exception = true
|
19
|
-
|
20
|
-
condition.wait
|
21
|
-
xs.should == [:notified]
|
13
|
+
sleep 0.25
|
14
|
+
condition.notify
|
22
15
|
end
|
16
|
+
t.abort_on_exception = true
|
17
|
+
|
18
|
+
condition.wait
|
19
|
+
xs.should == [:notified]
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
26
23
|
describe "#notify" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
xs = []
|
32
|
-
|
33
|
-
t1 = Thread.new do
|
34
|
-
condition.wait
|
35
|
-
mutex.synchronize { xs << :notified1 }
|
36
|
-
end
|
37
|
-
t1.abort_on_exception = true
|
24
|
+
it "notifies a single thread waiting on the latch" do
|
25
|
+
mutex = Mutex.new
|
26
|
+
condition = described_class.new
|
27
|
+
xs = []
|
38
28
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
29
|
+
t1 = Thread.new do
|
30
|
+
condition.wait
|
31
|
+
mutex.synchronize { xs << :notified1 }
|
32
|
+
end
|
33
|
+
t1.abort_on_exception = true
|
44
34
|
|
45
|
-
|
46
|
-
condition.
|
47
|
-
|
48
|
-
xs.should satisfy { |ys| ys.size == 1 && (ys.include?(:notified1) || ys.include?(:notified2)) }
|
35
|
+
t2 = Thread.new do
|
36
|
+
condition.wait
|
37
|
+
mutex.synchronize { xs << :notified2 }
|
49
38
|
end
|
39
|
+
t2.abort_on_exception = true
|
40
|
+
|
41
|
+
sleep 0.25
|
42
|
+
condition.notify
|
43
|
+
sleep 0.5
|
44
|
+
xs.should satisfy { |ys| ys.size == 1 && (ys.include?(:notified1) || ys.include?(:notified2)) }
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
53
48
|
describe "#notify_all" do
|
54
|
-
let(:n) {
|
49
|
+
let(:n) { 120 }
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@xs = []
|
51
|
+
it "notifies all the threads waiting on the latch" do
|
52
|
+
mutex = Mutex.new
|
53
|
+
condition = described_class.new
|
54
|
+
@xs = []
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
t.abort_on_exception = true
|
56
|
+
n.times do |i|
|
57
|
+
t = Thread.new do
|
58
|
+
condition.wait
|
59
|
+
mutex.synchronize { @xs << "notified#{i + 1}".to_sym }
|
68
60
|
end
|
61
|
+
t.abort_on_exception = true
|
62
|
+
end
|
69
63
|
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
sleep 0.5
|
65
|
+
condition.notify_all
|
66
|
+
sleep 0.5
|
73
67
|
|
74
|
-
|
75
|
-
|
68
|
+
n.times do |i|
|
69
|
+
item = "notified#{i + 1}".to_sym
|
76
70
|
|
77
|
-
|
78
|
-
end
|
71
|
+
@xs.should include(item)
|
79
72
|
end
|
80
73
|
end
|
81
74
|
end
|