bunny 1.7.0 → 2.17.0
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 +5 -5
- data/.github/ISSUE_TEMPLATE.md +18 -0
- data/.gitignore +6 -1
- data/.rspec +1 -3
- data/.travis.yml +21 -14
- data/CONTRIBUTING.md +132 -0
- data/ChangeLog.md +745 -1
- data/Gemfile +13 -13
- data/LICENSE +1 -1
- data/README.md +41 -75
- data/Rakefile +54 -0
- data/bunny.gemspec +4 -10
- data/docker-compose.yml +28 -0
- data/docker/Dockerfile +24 -0
- data/docker/apt/preferences.d/erlang +3 -0
- data/docker/apt/sources.list.d/bintray.rabbitmq.list +2 -0
- data/docker/docker-entrypoint.sh +26 -0
- data/docker/rabbitmq.conf +29 -0
- data/examples/connection/automatic_recovery_with_basic_get.rb +1 -1
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +1 -1
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +1 -1
- data/examples/connection/automatic_recovery_with_republishing.rb +1 -1
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +1 -1
- data/examples/connection/channel_level_exception.rb +1 -9
- data/examples/connection/disabled_automatic_recovery.rb +1 -1
- data/examples/connection/heartbeat.rb +1 -1
- data/examples/consumers/high_and_low_priority.rb +1 -1
- data/examples/guides/extensions/alternate_exchange.rb +2 -0
- data/examples/guides/getting_started/hello_world.rb +2 -0
- data/examples/guides/getting_started/weathr.rb +2 -0
- data/examples/guides/queues/one_off_consumer.rb +2 -0
- data/examples/guides/queues/redeliveries.rb +2 -0
- data/lib/bunny.rb +6 -2
- data/lib/bunny/channel.rb +192 -109
- data/lib/bunny/channel_id_allocator.rb +6 -4
- data/lib/bunny/concurrent/continuation_queue.rb +34 -13
- data/lib/bunny/consumer_work_pool.rb +34 -6
- data/lib/bunny/cruby/socket.rb +29 -16
- data/lib/bunny/cruby/ssl_socket.rb +20 -7
- data/lib/bunny/exceptions.rb +7 -1
- data/lib/bunny/exchange.rb +11 -7
- data/lib/bunny/get_response.rb +1 -1
- data/lib/bunny/heartbeat_sender.rb +3 -2
- data/lib/bunny/jruby/socket.rb +23 -6
- data/lib/bunny/jruby/ssl_socket.rb +5 -0
- data/lib/bunny/queue.rb +12 -10
- data/lib/bunny/reader_loop.rb +31 -18
- data/lib/bunny/session.rb +389 -134
- data/lib/bunny/test_kit.rb +14 -0
- data/lib/bunny/timeout.rb +1 -12
- data/lib/bunny/transport.rb +114 -67
- data/lib/bunny/version.rb +1 -1
- data/repl +1 -1
- data/spec/config/rabbitmq.conf +13 -0
- data/spec/higher_level_api/integration/basic_ack_spec.rb +154 -22
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +77 -11
- data/spec/higher_level_api/integration/basic_consume_spec.rb +60 -55
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +6 -6
- data/spec/higher_level_api/integration/basic_get_spec.rb +31 -7
- data/spec/higher_level_api/integration/basic_nack_spec.rb +22 -19
- data/spec/higher_level_api/integration/basic_publish_spec.rb +11 -100
- data/spec/higher_level_api/integration/basic_qos_spec.rb +32 -4
- data/spec/higher_level_api/integration/basic_reject_spec.rb +94 -16
- data/spec/higher_level_api/integration/basic_return_spec.rb +4 -4
- data/spec/higher_level_api/integration/channel_close_spec.rb +51 -10
- data/spec/higher_level_api/integration/channel_open_spec.rb +12 -12
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +412 -286
- data/spec/higher_level_api/integration/connection_spec.rb +284 -134
- data/spec/higher_level_api/integration/connection_stop_spec.rb +31 -19
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +17 -17
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +14 -14
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +5 -5
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +32 -31
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +12 -12
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +5 -5
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +5 -5
- data/spec/higher_level_api/integration/heartbeat_spec.rb +4 -4
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +49 -49
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +2 -2
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +92 -27
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +19 -19
- data/spec/higher_level_api/integration/queue_bind_spec.rb +23 -23
- data/spec/higher_level_api/integration/queue_declare_spec.rb +129 -34
- data/spec/higher_level_api/integration/queue_delete_spec.rb +2 -2
- data/spec/higher_level_api/integration/queue_purge_spec.rb +5 -5
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +6 -6
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +9 -9
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +10 -10
- data/spec/higher_level_api/integration/tls_connection_spec.rb +218 -112
- data/spec/higher_level_api/integration/toxiproxy_spec.rb +76 -0
- 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/higher_level_api/integration/with_channel_spec.rb +2 -2
- data/spec/issues/issue100_spec.rb +11 -12
- data/spec/issues/issue141_spec.rb +13 -14
- data/spec/issues/issue202_spec.rb +1 -1
- data/spec/issues/issue224_spec.rb +5 -5
- data/spec/issues/issue465_spec.rb +32 -0
- data/spec/issues/issue549_spec.rb +30 -0
- data/spec/issues/issue78_spec.rb +21 -24
- data/spec/issues/issue83_spec.rb +5 -6
- data/spec/issues/issue97_spec.rb +44 -45
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +15 -16
- data/spec/lower_level_api/integration/basic_consume_spec.rb +20 -21
- data/spec/spec_helper.rb +2 -19
- data/spec/stress/channel_close_stress_spec.rb +3 -3
- data/spec/stress/channel_open_stress_spec.rb +4 -4
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +7 -7
- data/spec/stress/concurrent_consumers_stress_spec.rb +18 -16
- data/spec/stress/concurrent_publishers_stress_spec.rb +16 -19
- data/spec/stress/connection_open_close_spec.rb +9 -9
- data/spec/stress/merry_go_round_spec.rb +105 -0
- data/spec/tls/ca_certificate.pem +27 -16
- data/spec/tls/ca_key.pem +52 -27
- data/spec/tls/client_certificate.pem +27 -16
- data/spec/tls/client_key.pem +49 -25
- data/spec/tls/generate-server-cert.sh +8 -0
- data/spec/tls/server-openssl.cnf +10 -0
- data/spec/tls/server.csr +16 -0
- data/spec/tls/server_certificate.pem +27 -16
- data/spec/tls/server_key.pem +49 -25
- data/spec/toxiproxy_helper.rb +28 -0
- data/spec/unit/bunny_spec.rb +5 -5
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +6 -6
- data/spec/unit/concurrent/condition_spec.rb +8 -8
- data/spec/unit/concurrent/linked_continuation_queue_spec.rb +2 -2
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +16 -16
- data/spec/unit/exchange_recovery_spec.rb +39 -0
- data/spec/unit/version_delivery_tag_spec.rb +3 -3
- metadata +42 -35
- data/lib/bunny/system_timer.rb +0 -20
- data/spec/config/rabbitmq.config +0 -18
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
- data/spec/stress/long_running_consumer_spec.rb +0 -83
- data/spec/tls/cacert.pem +0 -18
- data/spec/tls/client_cert.pem +0 -18
- data/spec/tls/server_cert.pem +0 -18
- data/spec/unit/system_timer_spec.rb +0 -10
@@ -4,66 +4,78 @@ describe Bunny::Session do
|
|
4
4
|
let(:http_client) { RabbitMQ::HTTP::Client.new("http://127.0.0.1:15672") }
|
5
5
|
|
6
6
|
def close_connection(client_port)
|
7
|
+
# let whatever actions were taken before
|
8
|
+
# this call a chance to propagate, e.g. to make
|
9
|
+
# sure that connections are accounted for in the
|
10
|
+
# stats DB.
|
11
|
+
#
|
12
|
+
# See bin/ci/before_build for management plugin
|
13
|
+
# pre-configuration.
|
14
|
+
#
|
15
|
+
# MK.
|
16
|
+
sleep 1.1
|
7
17
|
c = http_client.
|
8
18
|
list_connections.
|
9
|
-
find { |conn_info| conn_info.peer_port.to_i == client_port }
|
19
|
+
find { |conn_info| conn_info && conn_info.peer_port.to_i == client_port }
|
10
20
|
|
11
|
-
http_client.close_connection(c.name)
|
21
|
+
http_client.close_connection(c.name) if c
|
12
22
|
end
|
13
23
|
|
14
24
|
def wait_for_recovery
|
15
|
-
sleep
|
25
|
+
sleep 1.5
|
16
26
|
end
|
17
27
|
|
18
28
|
it "can be closed" do
|
19
|
-
c = Bunny.new(:
|
29
|
+
c = Bunny.new(automatically_recover: false)
|
20
30
|
c.start
|
21
31
|
ch = c.create_channel
|
22
32
|
|
23
|
-
c.
|
33
|
+
expect(c).to be_connected
|
24
34
|
c.stop
|
25
|
-
c.
|
35
|
+
expect(c).to be_closed
|
26
36
|
end
|
27
37
|
|
28
38
|
it "can be closed twice (Session#close is idempotent)" do
|
29
|
-
c = Bunny.new(:
|
39
|
+
c = Bunny.new(automatically_recover: false)
|
30
40
|
c.start
|
31
41
|
ch = c.create_channel
|
32
42
|
|
33
|
-
c.
|
43
|
+
expect(c).to be_connected
|
34
44
|
c.stop
|
35
|
-
c.
|
45
|
+
expect(c).to be_closed
|
36
46
|
c.stop
|
37
|
-
c.
|
47
|
+
expect(c).to be_closed
|
38
48
|
end
|
39
49
|
|
40
50
|
describe "in a single threaded mode" do
|
41
51
|
it "can be closed" do
|
42
|
-
c = Bunny.new(:
|
52
|
+
c = Bunny.new(automatically_recover: false, threaded: false)
|
43
53
|
c.start
|
44
54
|
ch = c.create_channel
|
45
55
|
|
46
|
-
c.
|
56
|
+
expect(c).to be_connected
|
47
57
|
c.stop
|
48
|
-
c.
|
58
|
+
expect(c).to be_closed
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
52
62
|
|
53
63
|
describe "that recovers from connection.close" do
|
54
64
|
it "can be closed" do
|
55
|
-
c = Bunny.new(
|
65
|
+
c = Bunny.new(automatically_recover: true,
|
66
|
+
recover_from_connection_close: true,
|
67
|
+
network_recovery_interval: 0.2)
|
56
68
|
c.start
|
57
69
|
ch = c.create_channel
|
58
70
|
|
59
|
-
|
71
|
+
sleep 1.5
|
72
|
+
expect(c).to be_open
|
73
|
+
sleep 1.5
|
60
74
|
close_connection(c.local_port)
|
61
|
-
sleep 0.2
|
62
|
-
c.should_not be_open
|
63
75
|
|
64
76
|
wait_for_recovery
|
65
|
-
c.
|
66
|
-
ch.
|
77
|
+
expect(c).to be_open
|
78
|
+
expect(ch).to be_open
|
67
79
|
|
68
80
|
c.close
|
69
81
|
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Channel do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -20,21 +20,21 @@ describe Bunny::Channel do
|
|
20
20
|
ch = connection.create_channel
|
21
21
|
t = Thread.new do
|
22
22
|
ch2 = connection.create_channel
|
23
|
-
q = ch2.queue(queue_name, :
|
23
|
+
q = ch2.queue(queue_name, auto_delete: true)
|
24
24
|
|
25
|
-
q.subscribe(:
|
25
|
+
q.subscribe(on_cancellation: Proc.new { cancelled = true })
|
26
26
|
end
|
27
27
|
t.abort_on_exception = true
|
28
28
|
|
29
29
|
sleep 0.5
|
30
30
|
x = ch.default_exchange
|
31
|
-
x.publish("abc", :
|
31
|
+
x.publish("abc", routing_key: queue_name)
|
32
32
|
|
33
33
|
sleep 0.5
|
34
|
-
ch.queue(queue_name, :
|
34
|
+
ch.queue(queue_name, auto_delete: true).delete
|
35
35
|
|
36
36
|
sleep 0.5
|
37
|
-
cancelled.
|
37
|
+
expect(cancelled).to eq true
|
38
38
|
|
39
39
|
ch.close
|
40
40
|
end
|
@@ -60,7 +60,7 @@ describe Bunny::Channel do
|
|
60
60
|
ch = connection.create_channel
|
61
61
|
t = Thread.new do
|
62
62
|
ch2 = connection.create_channel
|
63
|
-
q = ch2.queue(queue_name, :
|
63
|
+
q = ch2.queue(queue_name, auto_delete: true)
|
64
64
|
|
65
65
|
consumer = ExampleConsumer.new(ch2, q, "")
|
66
66
|
q.subscribe_with(consumer)
|
@@ -69,13 +69,13 @@ describe Bunny::Channel do
|
|
69
69
|
|
70
70
|
sleep 0.5
|
71
71
|
x = ch.default_exchange
|
72
|
-
x.publish("abc", :
|
72
|
+
x.publish("abc", routing_key: queue_name)
|
73
73
|
|
74
74
|
sleep 0.5
|
75
|
-
ch.queue(queue_name, :
|
75
|
+
ch.queue(queue_name, auto_delete: true).delete
|
76
76
|
|
77
77
|
sleep 0.5
|
78
|
-
consumer.
|
78
|
+
expect(consumer).to be_cancelled
|
79
79
|
|
80
80
|
ch.close
|
81
81
|
end
|
@@ -86,7 +86,7 @@ describe Bunny::Channel do
|
|
86
86
|
context "with consumer re-registration" do
|
87
87
|
class ExampleConsumerThatReregisters < Bunny::Consumer
|
88
88
|
def handle_cancellation(_)
|
89
|
-
@queue = @channel.queue("basic.consume.after_cancellation", :
|
89
|
+
@queue = @channel.queue("basic.consume.after_cancellation", auto_delete: true)
|
90
90
|
@channel.basic_consume_with(self)
|
91
91
|
end
|
92
92
|
end
|
@@ -100,7 +100,7 @@ describe Bunny::Channel do
|
|
100
100
|
ch = connection.create_channel
|
101
101
|
t = Thread.new do
|
102
102
|
ch2 = connection.create_channel
|
103
|
-
q = ch2.queue(queue_name, :
|
103
|
+
q = ch2.queue(queue_name, auto_delete: true)
|
104
104
|
|
105
105
|
consumer = ExampleConsumerThatReregisters.new(ch2, q, "")
|
106
106
|
consumer.on_delivery do |_, _, payload|
|
@@ -112,15 +112,15 @@ describe Bunny::Channel do
|
|
112
112
|
|
113
113
|
sleep 0.5
|
114
114
|
x = ch.default_exchange
|
115
|
-
x.publish("abc", :
|
115
|
+
x.publish("abc", routing_key: queue_name)
|
116
116
|
|
117
117
|
sleep 0.5
|
118
|
-
ch.queue(queue_name, :
|
118
|
+
ch.queue(queue_name, auto_delete: true).delete
|
119
119
|
|
120
|
-
x.publish("abc", :
|
120
|
+
x.publish("abc", routing_key: queue_name)
|
121
121
|
sleep 0.5
|
122
|
-
q = ch.queue("basic.consume.after_cancellation", :
|
123
|
-
xs.
|
122
|
+
q = ch.queue("basic.consume.after_cancellation", auto_delete: true)
|
123
|
+
expect(xs).to eq ["abc"]
|
124
124
|
|
125
125
|
ch.close
|
126
126
|
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "A message" do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -15,23 +15,23 @@ describe "A message" do
|
|
15
15
|
ch = connection.create_channel
|
16
16
|
x = ch.fanout("amq.fanout")
|
17
17
|
dlx = ch.fanout("bunny.tests.dlx.exchange")
|
18
|
-
q = ch.queue("", :
|
18
|
+
q = ch.queue("", exclusive: true, arguments: {"x-dead-letter-exchange" => dlx.name}).bind(x)
|
19
19
|
# dead letter queue
|
20
|
-
dlq = ch.queue("", :
|
20
|
+
dlq = ch.queue("", exclusive: true).bind(dlx)
|
21
21
|
|
22
22
|
x.publish("")
|
23
23
|
sleep 0.2
|
24
24
|
|
25
|
-
delivery_info, _, _ = q.pop(:
|
26
|
-
dlq.message_count.
|
25
|
+
delivery_info, _, _ = q.pop(manual_ack: true)
|
26
|
+
expect(dlq.message_count).to be_zero
|
27
27
|
ch.nack(delivery_info.delivery_tag)
|
28
28
|
|
29
29
|
sleep 0.2
|
30
|
-
q.message_count.
|
30
|
+
expect(q.message_count).to be_zero
|
31
31
|
|
32
32
|
delivery, properties, body = dlq.pop
|
33
33
|
ds = properties.headers["x-death"]
|
34
|
-
ds.
|
34
|
+
expect(ds).not_to be_empty
|
35
35
|
expect(ds.first["reason"]).to eq("rejected")
|
36
36
|
|
37
37
|
dlx.delete
|
@@ -41,15 +41,15 @@ describe "A message" do
|
|
41
41
|
ch = connection.create_channel
|
42
42
|
x = ch.fanout("amq.fanout")
|
43
43
|
dlx = ch.fanout("bunny.tests.dlx.exchange")
|
44
|
-
q = ch.queue("", :
|
44
|
+
q = ch.queue("", exclusive: true, arguments: {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
|
45
45
|
# dead letter queue
|
46
|
-
dlq = ch.queue("", :
|
46
|
+
dlq = ch.queue("", exclusive: true).bind(dlx)
|
47
47
|
|
48
48
|
x.publish("")
|
49
49
|
sleep 0.2
|
50
50
|
|
51
|
-
q.message_count.
|
52
|
-
dlq.message_count.
|
51
|
+
expect(q.message_count).to be_zero
|
52
|
+
expect(dlq.message_count).to eq 1
|
53
53
|
|
54
54
|
dlx.delete
|
55
55
|
end
|
@@ -58,16 +58,16 @@ describe "A message" do
|
|
58
58
|
ch = connection.create_channel
|
59
59
|
x = ch.fanout("amq.fanout")
|
60
60
|
dlx = ch.fanout("bunny.tests.dlx.exchange")
|
61
|
-
q = ch.queue("", :
|
61
|
+
q = ch.queue("", exclusive: true, arguments: {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
|
62
62
|
# dead letter queue
|
63
|
-
dlq = ch.queue("", :
|
63
|
+
dlq = ch.queue("", exclusive: true).bind(dlx)
|
64
64
|
|
65
65
|
x.publish("")
|
66
66
|
sleep 0.2
|
67
67
|
|
68
68
|
delivery, properties, body = dlq.pop
|
69
69
|
ds = properties.headers["x-death"]
|
70
|
-
ds.
|
70
|
+
expect(ds).not_to be_empty
|
71
71
|
expect(ds.first["reason"]).to eq("expired")
|
72
72
|
|
73
73
|
dlx.delete
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Exchange do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -14,17 +14,17 @@ describe Bunny::Exchange do
|
|
14
14
|
it "binds two existing exchanges" do
|
15
15
|
ch = connection.create_channel
|
16
16
|
|
17
|
-
source = ch.fanout("bunny.exchanges.source", :
|
18
|
-
destination = ch.fanout("bunny.exchanges.destination", :
|
17
|
+
source = ch.fanout("bunny.exchanges.source", auto_delete: true)
|
18
|
+
destination = ch.fanout("bunny.exchanges.destination", auto_delete: true)
|
19
19
|
|
20
|
-
queue = ch.queue("", :
|
20
|
+
queue = ch.queue("", exclusive: true)
|
21
21
|
queue.bind(destination)
|
22
22
|
|
23
23
|
destination.bind(source)
|
24
24
|
source.publish("")
|
25
25
|
sleep 0.5
|
26
26
|
|
27
|
-
queue.message_count.
|
27
|
+
expect(queue.message_count).to be > 0
|
28
28
|
|
29
29
|
ch.close
|
30
30
|
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Exchange do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -17,7 +17,7 @@ describe Bunny::Exchange do
|
|
17
17
|
|
18
18
|
x = Bunny::Exchange.default(ch)
|
19
19
|
|
20
|
-
x.name.
|
20
|
+
expect(x.name).to eq ''
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -28,7 +28,7 @@ describe Bunny::Exchange do
|
|
28
28
|
|
29
29
|
name = "bunny.tests.exchanges.fanout#{rand}"
|
30
30
|
x = ch.fanout(name)
|
31
|
-
x.name.
|
31
|
+
expect(x.name).to eq name
|
32
32
|
|
33
33
|
x.delete
|
34
34
|
ch.close
|
@@ -41,7 +41,7 @@ describe Bunny::Exchange do
|
|
41
41
|
|
42
42
|
name = "amq.fanout"
|
43
43
|
x = ch.fanout(name)
|
44
|
-
x.name.
|
44
|
+
expect(x.name).to eq name
|
45
45
|
|
46
46
|
ch.close
|
47
47
|
end
|
@@ -55,7 +55,7 @@ describe Bunny::Exchange do
|
|
55
55
|
ch.fanout("amq.test")
|
56
56
|
}.to raise_error(Bunny::AccessRefused)
|
57
57
|
|
58
|
-
ch.
|
58
|
+
expect(ch).to be_closed
|
59
59
|
expect {
|
60
60
|
ch.fanout("amq.test")
|
61
61
|
}.to raise_error(Bunny::ChannelAlreadyClosed)
|
@@ -67,10 +67,10 @@ describe Bunny::Exchange do
|
|
67
67
|
ch = connection.create_channel
|
68
68
|
|
69
69
|
name = "bunny.tests.exchanges.durable"
|
70
|
-
x = ch.fanout(name, :
|
71
|
-
x.name.
|
72
|
-
x.
|
73
|
-
x.
|
70
|
+
x = ch.fanout(name, durable: true)
|
71
|
+
expect(x.name).to eq name
|
72
|
+
expect(x).to be_durable
|
73
|
+
expect(x).not_to be_auto_delete
|
74
74
|
|
75
75
|
x.delete
|
76
76
|
ch.close
|
@@ -83,12 +83,12 @@ describe Bunny::Exchange do
|
|
83
83
|
ch = connection.create_channel
|
84
84
|
|
85
85
|
name = "bunny.tests.exchanges.auto-delete"
|
86
|
-
x = ch.fanout(name, :
|
87
|
-
x.name.
|
88
|
-
x.
|
89
|
-
x.
|
86
|
+
x = ch.fanout(name, auto_delete: true)
|
87
|
+
expect(x.name).to eq name
|
88
|
+
expect(x).not_to be_durable
|
89
|
+
expect(x).to be_auto_delete
|
90
90
|
|
91
|
-
ch.exchange(name, :
|
91
|
+
ch.exchange(name, type: :fanout, auto_delete: true)
|
92
92
|
|
93
93
|
x.delete
|
94
94
|
ch.close
|
@@ -98,17 +98,18 @@ describe Bunny::Exchange do
|
|
98
98
|
|
99
99
|
context "when declared with a different set of attributes" do
|
100
100
|
it "raises an exception" do
|
101
|
-
|
101
|
+
ch1 = connection.create_channel
|
102
|
+
ch2 = connection.create_channel
|
102
103
|
|
103
|
-
x =
|
104
|
+
x = ch1.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
|
104
105
|
expect {
|
105
106
|
# force re-declaration
|
106
|
-
|
107
|
+
ch2.exchange_declare("bunny.tests.exchanges.fanout", :direct, auto_delete: false, durable: true)
|
107
108
|
}.to raise_error(Bunny::PreconditionFailed)
|
108
109
|
|
109
|
-
|
110
|
+
expect(ch2).to be_closed
|
110
111
|
expect {
|
111
|
-
|
112
|
+
ch2.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
|
112
113
|
}.to raise_error(Bunny::ChannelAlreadyClosed)
|
113
114
|
end
|
114
115
|
end
|
@@ -121,9 +122,9 @@ describe Bunny::Exchange do
|
|
121
122
|
|
122
123
|
name = "bunny.tests.exchanges.direct"
|
123
124
|
x = ch.direct(name)
|
124
|
-
x.name.
|
125
|
+
expect(x.name).to eq name
|
125
126
|
|
126
|
-
ch.exchange(name, :
|
127
|
+
ch.exchange(name, type: :direct)
|
127
128
|
|
128
129
|
x.delete
|
129
130
|
ch.close
|
@@ -136,7 +137,7 @@ describe Bunny::Exchange do
|
|
136
137
|
|
137
138
|
name = "amq.direct"
|
138
139
|
x = ch.direct(name)
|
139
|
-
x.name.
|
140
|
+
expect(x.name).to eq name
|
140
141
|
|
141
142
|
ch.close
|
142
143
|
end
|
@@ -150,9 +151,9 @@ describe Bunny::Exchange do
|
|
150
151
|
|
151
152
|
name = "bunny.tests.exchanges.topic"
|
152
153
|
x = ch.topic(name)
|
153
|
-
x.name.
|
154
|
+
expect(x.name).to eq name
|
154
155
|
|
155
|
-
ch.exchange(name, :
|
156
|
+
ch.exchange(name, type: :topic)
|
156
157
|
|
157
158
|
x.delete
|
158
159
|
ch.close
|
@@ -165,7 +166,7 @@ describe Bunny::Exchange do
|
|
165
166
|
|
166
167
|
name = "amq.topic"
|
167
168
|
x = ch.topic(name)
|
168
|
-
x.name.
|
169
|
+
expect(x.name).to eq name
|
169
170
|
|
170
171
|
ch.close
|
171
172
|
end
|
@@ -179,7 +180,7 @@ describe Bunny::Exchange do
|
|
179
180
|
|
180
181
|
name = "bunny.tests.exchanges.headers"
|
181
182
|
x = ch.headers(name)
|
182
|
-
x.name.
|
183
|
+
expect(x.name).to eq name
|
183
184
|
|
184
185
|
x.delete
|
185
186
|
ch.close
|
@@ -192,7 +193,7 @@ describe Bunny::Exchange do
|
|
192
193
|
|
193
194
|
name = "amq.match"
|
194
195
|
x = ch.headers(name)
|
195
|
-
x.name.
|
196
|
+
expect(x.name).to eq name
|
196
197
|
|
197
198
|
ch.close
|
198
199
|
end
|
@@ -204,7 +205,7 @@ describe Bunny::Exchange do
|
|
204
205
|
|
205
206
|
name = "amq.headers"
|
206
207
|
x = ch.headers(name)
|
207
|
-
x.name.
|
208
|
+
expect(x.name).to eq name
|
208
209
|
|
209
210
|
ch.close
|
210
211
|
end
|
@@ -215,8 +216,8 @@ describe Bunny::Exchange do
|
|
215
216
|
context "that is internal" do
|
216
217
|
it "can be declared" do
|
217
218
|
ch = connection.create_channel
|
218
|
-
x = ch.fanout("bunny.tests.exchanges.internal", :
|
219
|
-
x.
|
219
|
+
x = ch.fanout("bunny.tests.exchanges.internal", internal: true)
|
220
|
+
expect(x).to be_internal
|
220
221
|
x.delete
|
221
222
|
|
222
223
|
ch.close
|
@@ -227,7 +228,7 @@ describe Bunny::Exchange do
|
|
227
228
|
it "is not internal" do
|
228
229
|
ch = connection.create_channel
|
229
230
|
x = ch.fanout("bunny.tests.exchanges.non-internal")
|
230
|
-
x.
|
231
|
+
expect(x).not_to be_internal
|
231
232
|
x.delete
|
232
233
|
|
233
234
|
ch.close
|