bunny 1.0.7 → 2.24.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/README.md +92 -87
- data/lib/amq/protocol/extensions.rb +2 -0
- data/lib/bunny/authentication/credentials_encoder.rb +2 -0
- data/lib/bunny/authentication/external_mechanism_encoder.rb +2 -0
- data/lib/bunny/authentication/plain_mechanism_encoder.rb +2 -0
- data/lib/bunny/channel.rb +485 -186
- data/lib/bunny/channel_id_allocator.rb +8 -4
- data/lib/bunny/concurrent/atomic_fixnum.rb +2 -0
- data/lib/bunny/concurrent/condition.rb +2 -0
- data/lib/bunny/concurrent/continuation_queue.rb +37 -13
- data/lib/bunny/concurrent/synchronized_sorted_set.rb +2 -0
- data/lib/bunny/consumer.rb +20 -13
- data/lib/bunny/consumer_tag_generator.rb +6 -2
- data/lib/bunny/consumer_work_pool.rb +37 -7
- data/lib/bunny/cruby/socket.rb +51 -22
- data/lib/bunny/cruby/ssl_socket.rb +68 -5
- data/lib/bunny/delivery_info.rb +3 -1
- data/lib/bunny/exceptions.rb +27 -4
- data/lib/bunny/exchange.rb +35 -29
- data/lib/bunny/framing.rb +2 -0
- data/lib/bunny/get_response.rb +85 -0
- data/lib/bunny/heartbeat_sender.rb +9 -6
- data/lib/bunny/message_properties.rb +2 -0
- data/lib/bunny/queue.rb +89 -41
- data/lib/bunny/reader_loop.rb +72 -28
- data/lib/bunny/return_info.rb +2 -0
- data/lib/bunny/session.rb +621 -225
- data/lib/bunny/socket.rb +7 -12
- data/lib/bunny/ssl_socket.rb +7 -12
- data/lib/bunny/test_kit.rb +15 -0
- data/lib/bunny/timeout.rb +3 -12
- data/lib/bunny/timestamp.rb +24 -0
- data/lib/bunny/transport.rb +223 -98
- data/lib/bunny/version.rb +2 -1
- data/lib/bunny/versioned_delivery_tag.rb +2 -0
- data/lib/bunny.rb +54 -8
- metadata +38 -224
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.travis.yml +0 -23
- data/.yardopts +0 -8
- data/ChangeLog.md +0 -1092
- data/Gemfile +0 -54
- data/LICENSE +0 -21
- data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
- data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
- data/benchmarks/channel_open.rb +0 -28
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/queue_declare.rb +0 -29
- data/benchmarks/queue_declare_and_bind.rb +0 -29
- data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/benchmarks/write_vs_write_nonblock.rb +0 -49
- data/bin/ci/before_build.sh +0 -31
- data/bunny.gemspec +0 -40
- data/examples/connection/authentication_failure.rb +0 -16
- data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
- data/examples/connection/channel_level_exception.rb +0 -35
- data/examples/connection/disabled_automatic_recovery.rb +0 -34
- data/examples/connection/heartbeat.rb +0 -17
- data/examples/connection/manually_reconnecting_consumer.rb +0 -23
- data/examples/connection/manually_reconnecting_publisher.rb +0 -28
- data/examples/connection/unknown_host.rb +0 -16
- data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
- data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
- data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
- data/examples/guides/exchanges/mandatory_messages.rb +0 -30
- data/examples/guides/extensions/alternate_exchange.rb +0 -28
- data/examples/guides/extensions/basic_nack.rb +0 -33
- data/examples/guides/extensions/connection_blocked.rb +0 -35
- data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
- data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
- data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
- data/examples/guides/extensions/per_message_ttl.rb +0 -36
- data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
- data/examples/guides/extensions/publisher_confirms.rb +0 -28
- data/examples/guides/extensions/queue_lease.rb +0 -26
- data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
- data/examples/guides/getting_started/blabbr.rb +0 -27
- data/examples/guides/getting_started/hello_world.rb +0 -20
- data/examples/guides/getting_started/weathr.rb +0 -47
- data/examples/guides/queues/one_off_consumer.rb +0 -23
- data/examples/guides/queues/redeliveries.rb +0 -79
- data/lib/bunny/compatibility.rb +0 -24
- data/lib/bunny/concurrent/linked_continuation_queue.rb +0 -61
- data/lib/bunny/jruby/socket.rb +0 -40
- data/lib/bunny/jruby/ssl_socket.rb +0 -53
- data/lib/bunny/system_timer.rb +0 -20
- data/profiling/basic_publish/with_4K_messages.rb +0 -33
- data/repl +0 -3
- data/spec/compatibility/queue_declare_spec.rb +0 -44
- data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
- data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -71
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -76
- data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -225
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
- data/spec/higher_level_api/integration/basic_get_spec.rb +0 -48
- data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -79
- data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -89
- data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -29
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -74
- data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
- data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
- data/spec/higher_level_api/integration/channel_flow_spec.rb +0 -21
- data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
- data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
- data/spec/higher_level_api/integration/connection_spec.rb +0 -400
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -52
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -204
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
- data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -31
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -77
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -65
- data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
- data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -190
- data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
- data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
- data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -127
- data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
- data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
- data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
- data/spec/issues/issue100_spec.rb +0 -42
- data/spec/issues/issue141_spec.rb +0 -44
- data/spec/issues/issue78_spec.rb +0 -75
- data/spec/issues/issue83_spec.rb +0 -31
- data/spec/issues/issue97_attachment.json +0 -1
- data/spec/issues/issue97_spec.rb +0 -176
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -69
- data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -64
- data/spec/stress/channel_open_stress_spec.rb +0 -51
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
- data/spec/stress/concurrent_consumers_stress_spec.rb +0 -69
- data/spec/stress/concurrent_publishers_stress_spec.rb +0 -57
- data/spec/stress/connection_open_close_spec.rb +0 -40
- 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/client_key.pem +0 -27
- data/spec/tls/server_cert.pem +0 -18
- data/spec/tls/server_key.pem +0 -27
- data/spec/unit/bunny_spec.rb +0 -15
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
- data/spec/unit/concurrent/condition_spec.rb +0 -82
- data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
- data/spec/unit/system_timer_spec.rb +0 -10
- data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,128 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
context "with implicit consumer construction" do
|
15
|
-
let(:queue_name) { "basic.consume#{rand}" }
|
16
|
-
|
17
|
-
it "supports consumer cancellation notifications" do
|
18
|
-
cancelled = false
|
19
|
-
|
20
|
-
ch = connection.create_channel
|
21
|
-
t = Thread.new do
|
22
|
-
ch2 = connection.create_channel
|
23
|
-
q = ch2.queue(queue_name, :auto_delete => true)
|
24
|
-
|
25
|
-
q.subscribe(:on_cancellation => Proc.new { cancelled = true })
|
26
|
-
end
|
27
|
-
t.abort_on_exception = true
|
28
|
-
|
29
|
-
sleep 0.5
|
30
|
-
x = ch.default_exchange
|
31
|
-
x.publish("abc", :routing_key => queue_name)
|
32
|
-
|
33
|
-
sleep 0.5
|
34
|
-
ch.queue(queue_name, :auto_delete => true).delete
|
35
|
-
|
36
|
-
sleep 0.5
|
37
|
-
cancelled.should be_true
|
38
|
-
|
39
|
-
ch.close
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
context "with explicit consumer construction" do
|
45
|
-
class ExampleConsumer < Bunny::Consumer
|
46
|
-
def cancelled?
|
47
|
-
@cancelled
|
48
|
-
end
|
49
|
-
|
50
|
-
def handle_cancellation(_)
|
51
|
-
@cancelled = true
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
let(:queue_name) { "basic.consume#{rand}" }
|
56
|
-
|
57
|
-
it "supports consumer cancellation notifications" do
|
58
|
-
consumer = nil
|
59
|
-
|
60
|
-
ch = connection.create_channel
|
61
|
-
t = Thread.new do
|
62
|
-
ch2 = connection.create_channel
|
63
|
-
q = ch2.queue(queue_name, :auto_delete => true)
|
64
|
-
|
65
|
-
consumer = ExampleConsumer.new(ch2, q, "")
|
66
|
-
q.subscribe_with(consumer)
|
67
|
-
end
|
68
|
-
t.abort_on_exception = true
|
69
|
-
|
70
|
-
sleep 0.5
|
71
|
-
x = ch.default_exchange
|
72
|
-
x.publish("abc", :routing_key => queue_name)
|
73
|
-
|
74
|
-
sleep 0.5
|
75
|
-
ch.queue(queue_name, :auto_delete => true).delete
|
76
|
-
|
77
|
-
sleep 0.5
|
78
|
-
consumer.should be_cancelled
|
79
|
-
|
80
|
-
ch.close
|
81
|
-
end
|
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
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "A message" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
it "is considered to be dead-lettered when it is rejected without requeueing" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
x = ch.fanout("amq.fanout")
|
17
|
-
dlx = ch.fanout("bunny.tests.dlx.exchange")
|
18
|
-
q = ch.queue("", :exclusive => true, :arguments => {"x-dead-letter-exchange" => dlx.name}).bind(x)
|
19
|
-
# dead letter queue
|
20
|
-
dlq = ch.queue("", :exclusive => true).bind(dlx)
|
21
|
-
|
22
|
-
x.publish("")
|
23
|
-
sleep 0.2
|
24
|
-
|
25
|
-
delivery_info, _, _ = q.pop(:ack => true)
|
26
|
-
dlq.message_count.should be_zero
|
27
|
-
ch.nack(delivery_info.delivery_tag)
|
28
|
-
|
29
|
-
sleep 0.2
|
30
|
-
q.message_count.should be_zero
|
31
|
-
dlq.message_count.should == 1
|
32
|
-
|
33
|
-
dlx.delete
|
34
|
-
end
|
35
|
-
|
36
|
-
it "is considered to be dead-lettered when it expires" do
|
37
|
-
ch = connection.create_channel
|
38
|
-
x = ch.fanout("amq.fanout")
|
39
|
-
dlx = ch.fanout("bunny.tests.dlx.exchange")
|
40
|
-
q = ch.queue("", :exclusive => true, :arguments => {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
|
41
|
-
# dead letter queue
|
42
|
-
dlq = ch.queue("", :exclusive => true).bind(dlx)
|
43
|
-
|
44
|
-
x.publish("")
|
45
|
-
sleep 0.2
|
46
|
-
|
47
|
-
q.message_count.should be_zero
|
48
|
-
dlq.message_count.should == 1
|
49
|
-
|
50
|
-
dlx.delete
|
51
|
-
end
|
52
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Exchange do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
it "binds two existing exchanges" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
|
17
|
-
source = ch.fanout("bunny.exchanges.source", :auto_delete => true)
|
18
|
-
destination = ch.fanout("bunny.exchanges.destination", :auto_delete => true)
|
19
|
-
|
20
|
-
queue = ch.queue("", :exclusive => true)
|
21
|
-
queue.bind(destination)
|
22
|
-
|
23
|
-
destination.bind(source)
|
24
|
-
source.publish("")
|
25
|
-
sleep 0.5
|
26
|
-
|
27
|
-
queue.message_count.should be > 0
|
28
|
-
|
29
|
-
ch.close
|
30
|
-
end
|
31
|
-
end
|
@@ -1,204 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Exchange do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
context "of type fanout" do
|
16
|
-
context "with a non-predefined name" do
|
17
|
-
it "is declared" do
|
18
|
-
ch = connection.create_channel
|
19
|
-
|
20
|
-
name = "bunny.tests.exchanges.fanout#{rand}"
|
21
|
-
x = ch.fanout(name)
|
22
|
-
x.name.should == name
|
23
|
-
|
24
|
-
x.delete
|
25
|
-
ch.close
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with a predefined name" do
|
30
|
-
it "is NOT declared" do
|
31
|
-
ch = connection.create_channel
|
32
|
-
|
33
|
-
name = "amq.fanout"
|
34
|
-
x = ch.fanout(name)
|
35
|
-
x.name.should == name
|
36
|
-
|
37
|
-
ch.close
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with a name prefixed with 'amq.'" do
|
42
|
-
it "raises an exception" do
|
43
|
-
ch = connection.create_channel
|
44
|
-
|
45
|
-
expect {
|
46
|
-
ch.fanout("amq.test")
|
47
|
-
}.to raise_error(Bunny::AccessRefused)
|
48
|
-
|
49
|
-
ch.should be_closed
|
50
|
-
expect {
|
51
|
-
ch.fanout("amq.test")
|
52
|
-
}.to raise_error(Bunny::ChannelAlreadyClosed)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "with the durable property" do
|
57
|
-
it "is declared as durable" do
|
58
|
-
ch = connection.create_channel
|
59
|
-
|
60
|
-
name = "bunny.tests.exchanges.durable"
|
61
|
-
x = ch.fanout(name, :durable => true)
|
62
|
-
x.name.should == name
|
63
|
-
x.should be_durable
|
64
|
-
x.should_not be_auto_delete
|
65
|
-
|
66
|
-
x.delete
|
67
|
-
ch.close
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
context "with the auto-delete property" do
|
73
|
-
it "is declared as auto-delete" do
|
74
|
-
ch = connection.create_channel
|
75
|
-
|
76
|
-
name = "bunny.tests.exchanges.auto-delete"
|
77
|
-
x = ch.fanout(name, :auto_delete => true)
|
78
|
-
x.name.should == name
|
79
|
-
x.should_not be_durable
|
80
|
-
x.should be_auto_delete
|
81
|
-
|
82
|
-
ch.exchange(name, :type => :fanout, :auto_delete => true)
|
83
|
-
|
84
|
-
x.delete
|
85
|
-
ch.close
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
context "when declared with a different set of attributes" do
|
91
|
-
it "raises an exception" do
|
92
|
-
ch = connection.create_channel
|
93
|
-
|
94
|
-
x = ch.fanout("bunny.tests.exchanges.fanout", :auto_delete => true, :durable => false)
|
95
|
-
expect {
|
96
|
-
# force re-declaration
|
97
|
-
ch.exchange_declare("bunny.tests.exchanges.fanout", :direct, :auto_delete => false, :durable => true)
|
98
|
-
}.to raise_error(Bunny::PreconditionFailed)
|
99
|
-
|
100
|
-
ch.should be_closed
|
101
|
-
expect {
|
102
|
-
ch.fanout("bunny.tests.exchanges.fanout", :auto_delete => true, :durable => false)
|
103
|
-
}.to raise_error(Bunny::ChannelAlreadyClosed)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "of type direct" do
|
109
|
-
context "with a non-predefined name" do
|
110
|
-
it "is declared" do
|
111
|
-
ch = connection.create_channel
|
112
|
-
|
113
|
-
name = "bunny.tests.exchanges.direct"
|
114
|
-
x = ch.direct(name)
|
115
|
-
x.name.should == name
|
116
|
-
|
117
|
-
ch.exchange(name, :type => :direct)
|
118
|
-
|
119
|
-
x.delete
|
120
|
-
ch.close
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "with a predefined name" do
|
125
|
-
it "is NOT declared" do
|
126
|
-
ch = connection.create_channel
|
127
|
-
|
128
|
-
name = "amq.direct"
|
129
|
-
x = ch.direct(name)
|
130
|
-
x.name.should == name
|
131
|
-
|
132
|
-
ch.close
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "of type topic" do
|
138
|
-
context "with a non-predefined name" do
|
139
|
-
it "is declared" do
|
140
|
-
ch = connection.create_channel
|
141
|
-
|
142
|
-
name = "bunny.tests.exchanges.topic"
|
143
|
-
x = ch.topic(name)
|
144
|
-
x.name.should == name
|
145
|
-
|
146
|
-
ch.exchange(name, :type => :topic)
|
147
|
-
|
148
|
-
x.delete
|
149
|
-
ch.close
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
context "with a predefined name" do
|
154
|
-
it "is NOT declared" do
|
155
|
-
ch = connection.create_channel
|
156
|
-
|
157
|
-
name = "amq.topic"
|
158
|
-
x = ch.topic(name)
|
159
|
-
x.name.should == name
|
160
|
-
|
161
|
-
ch.close
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "of type headers" do
|
167
|
-
context "with a non-predefined name" do
|
168
|
-
it "is declared" do
|
169
|
-
ch = connection.create_channel
|
170
|
-
|
171
|
-
name = "bunny.tests.exchanges.headers"
|
172
|
-
x = ch.headers(name)
|
173
|
-
x.name.should == name
|
174
|
-
|
175
|
-
x.delete
|
176
|
-
ch.close
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context "with a predefined name (amq.match)" do
|
181
|
-
it "is NOT declared" do
|
182
|
-
ch = connection.create_channel
|
183
|
-
|
184
|
-
name = "amq.match"
|
185
|
-
x = ch.headers(name)
|
186
|
-
x.name.should == name
|
187
|
-
|
188
|
-
ch.close
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context "with a predefined name (amq.headers)" do
|
193
|
-
it "is NOT declared" do
|
194
|
-
ch = connection.create_channel
|
195
|
-
|
196
|
-
name = "amq.headers"
|
197
|
-
x = ch.headers(name)
|
198
|
-
x.name.should == name
|
199
|
-
|
200
|
-
ch.close
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Exchange, "#delete" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
context "with a name of an existing exchange" do
|
16
|
-
it "deletes that exchange" do
|
17
|
-
ch = connection.create_channel
|
18
|
-
x = ch.fanout("bunny.tests.exchanges.fanout#{rand}")
|
19
|
-
|
20
|
-
x.delete
|
21
|
-
# no exception as of RabbitMQ 3.2. MK.
|
22
|
-
x.delete
|
23
|
-
|
24
|
-
ch.exchanges.size.should == 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
context "with a name of a non-existent exchange" do
|
30
|
-
it "DOES NOT rais an exception" do
|
31
|
-
ch = connection.create_channel
|
32
|
-
|
33
|
-
# no exception as of RabbitMQ 3.2. MK.
|
34
|
-
ch.exchange_delete("sdkhflsdjflskdjflsd#{rand}")
|
35
|
-
ch.exchange_delete("sdkhflsdjflskdjflsd#{rand}")
|
36
|
-
ch.exchange_delete("sdkhflsdjflskdjflsd#{rand}")
|
37
|
-
ch.exchange_delete("sdkhflsdjflskdjflsd#{rand}")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with a name of 'amq.direct'" do
|
42
|
-
it "does not delete the exchange" do
|
43
|
-
ch = connection.create_channel
|
44
|
-
x = ch.direct('amq.direct')
|
45
|
-
|
46
|
-
x.delete.should == nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with a name of 'amq.fanout'" do
|
51
|
-
it "does not delete the exchange" do
|
52
|
-
ch = connection.create_channel
|
53
|
-
x = ch.fanout('amq.fanout')
|
54
|
-
|
55
|
-
x.delete.should == nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with a name of 'amq.topic'" do
|
60
|
-
it "does not delete the exchange" do
|
61
|
-
ch = connection.create_channel
|
62
|
-
x = ch.topic('amq.topic')
|
63
|
-
|
64
|
-
x.delete.should == nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "with a name of 'amq.headers'" do
|
69
|
-
it "does not delete the exchange" do
|
70
|
-
ch = connection.create_channel
|
71
|
-
x = ch.headers('amq.headers')
|
72
|
-
|
73
|
-
x.delete.should == nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with a name of 'amq.match'" do
|
78
|
-
it "does not delete the exchange" do
|
79
|
-
ch = connection.create_channel
|
80
|
-
x = ch.headers('amq.match')
|
81
|
-
|
82
|
-
x.delete.should == nil
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
describe "#exchange_exists?" do
|
88
|
-
context "when a exchange exists" do
|
89
|
-
it "returns true" do
|
90
|
-
ch = connection.create_channel
|
91
|
-
|
92
|
-
connection.exchange_exists?("amq.fanout").should be_true
|
93
|
-
connection.exchange_exists?("amq.direct").should be_true
|
94
|
-
connection.exchange_exists?("amq.topic").should be_true
|
95
|
-
connection.exchange_exists?("amq.match").should be_true
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "when a exchange DOES NOT exist" do
|
100
|
-
it "returns false" do
|
101
|
-
connection.exchange_exists?("suf89u9a4jo3ndnakls##{Time.now.to_i}").should be_false
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Exchange do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
it "unbinds two existing exchanges" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
|
17
|
-
source = ch.fanout("bunny.exchanges.source#{rand}")
|
18
|
-
destination = ch.fanout("bunny.exchanges.destination#{rand}")
|
19
|
-
|
20
|
-
queue = ch.queue("", :exclusive => true)
|
21
|
-
queue.bind(destination)
|
22
|
-
|
23
|
-
destination.bind(source)
|
24
|
-
source.publish("")
|
25
|
-
sleep 0.5
|
26
|
-
|
27
|
-
queue.message_count.should be == 1
|
28
|
-
queue.pop(:ack => true)
|
29
|
-
|
30
|
-
destination.unbind(source)
|
31
|
-
source.publish("")
|
32
|
-
sleep 0.5
|
33
|
-
|
34
|
-
queue.message_count.should be == 0
|
35
|
-
|
36
|
-
source.delete
|
37
|
-
destination.delete
|
38
|
-
ch.close
|
39
|
-
end
|
40
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Queue do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
it "is closed when the connection it was declared on is closed" do
|
15
|
-
ch1 = connection.create_channel
|
16
|
-
ch2 = connection.create_channel
|
17
|
-
q = ch1.queue("", :exclusive => true)
|
18
|
-
|
19
|
-
ch1.queue_declare(q.name, :passive => true)
|
20
|
-
ch2.queue_declare(q.name, :passive => true)
|
21
|
-
|
22
|
-
ch1.close
|
23
|
-
ch2.queue_declare(q.name, :passive => true)
|
24
|
-
|
25
|
-
ch2.queue_delete(q.name)
|
26
|
-
ch2.close
|
27
|
-
end
|
28
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Client-defined heartbeat interval" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :heartbeat_interval => 4)
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
it "can be enabled explicitly" do
|
11
|
-
sleep 5.0
|
12
|
-
|
13
|
-
connection.close
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
describe "Server-defined heartbeat interval" do
|
19
|
-
let(:connection) do
|
20
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :heartbeat_interval => :server)
|
21
|
-
c.start
|
22
|
-
c
|
23
|
-
end
|
24
|
-
|
25
|
-
it "can be enabled explicitly" do
|
26
|
-
puts "Sleeping for 5 seconds with heartbeat interval of 4"
|
27
|
-
sleep 5.0
|
28
|
-
|
29
|
-
connection.close
|
30
|
-
end
|
31
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "A message that is proxied by multiple intermediate consumers" do
|
4
|
-
let(:c1) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:c2) do
|
11
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
12
|
-
c.start
|
13
|
-
c
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:c3) do
|
17
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
18
|
-
c.start
|
19
|
-
c
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:c4) do
|
23
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
24
|
-
c.start
|
25
|
-
c
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:c5) do
|
29
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
30
|
-
c.start
|
31
|
-
c
|
32
|
-
end
|
33
|
-
|
34
|
-
after :each do
|
35
|
-
[c1, c2, c3, c4, c5].each do |c|
|
36
|
-
c.close if c.open?
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# message flow is as follows:
|
41
|
-
#
|
42
|
-
# x => q4 => q3 => q2 => q1 => xs (results)
|
43
|
-
it "reaches its final destination" do
|
44
|
-
n = 10000
|
45
|
-
xs = []
|
46
|
-
|
47
|
-
ch1 = c1.create_channel
|
48
|
-
q1 = ch1.queue("", :exclusive => true)
|
49
|
-
q1.subscribe do |_, _, payload|
|
50
|
-
xs << payload
|
51
|
-
end
|
52
|
-
|
53
|
-
ch2 = c2.create_channel
|
54
|
-
q2 = ch2.queue("", :exclusive => true)
|
55
|
-
q2.subscribe do |_, _, payload|
|
56
|
-
q1.publish(payload)
|
57
|
-
end
|
58
|
-
|
59
|
-
ch3 = c3.create_channel
|
60
|
-
q3 = ch2.queue("", :exclusive => true)
|
61
|
-
q3.subscribe do |_, _, payload|
|
62
|
-
q2.publish(payload)
|
63
|
-
end
|
64
|
-
|
65
|
-
ch4 = c4.create_channel
|
66
|
-
q4 = ch2.queue("", :exclusive => true)
|
67
|
-
q4.subscribe do |_, _, payload|
|
68
|
-
q3.publish(payload)
|
69
|
-
end
|
70
|
-
|
71
|
-
ch5 = c5.create_channel
|
72
|
-
x = ch5.default_exchange
|
73
|
-
|
74
|
-
n.times do |i|
|
75
|
-
x.publish("msg #{i}", :routing_key => q4.name)
|
76
|
-
end
|
77
|
-
|
78
|
-
t = n / 1000 * 3.0
|
79
|
-
puts "About to sleep for #{t} seconds..."
|
80
|
-
sleep(t)
|
81
|
-
|
82
|
-
xs.size.should == n
|
83
|
-
xs.last.should == "msg #{n - 1}"
|
84
|
-
end
|
85
|
-
end
|