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,95 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Queue, "#subscribe" 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
|
-
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
15
|
-
|
16
|
-
it "provides delivery handler access to message properties" do
|
17
|
-
@now = Time.now
|
18
|
-
metadata = {}
|
19
|
-
envelope = {}
|
20
|
-
|
21
|
-
t = Thread.new do
|
22
|
-
ch = connection.create_channel
|
23
|
-
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
|
24
|
-
q.subscribe(:exclusive => true, :ack => false) do |delivery_info, properties, payload|
|
25
|
-
metadata = properties
|
26
|
-
envelope = delivery_info
|
27
|
-
end
|
28
|
-
end
|
29
|
-
t.abort_on_exception = true
|
30
|
-
sleep 0.5
|
31
|
-
|
32
|
-
ch = connection.create_channel
|
33
|
-
x = ch.default_exchange
|
34
|
-
x.publish("hello",
|
35
|
-
:routing_key => queue_name,
|
36
|
-
:app_id => "bunny.example",
|
37
|
-
:priority => 8,
|
38
|
-
:type => "kinda.checkin",
|
39
|
-
# headers table keys can be anything
|
40
|
-
:headers => {
|
41
|
-
:coordinates => {
|
42
|
-
:latitude => 59.35,
|
43
|
-
:longitude => 18.066667
|
44
|
-
},
|
45
|
-
:time => @now,
|
46
|
-
:participants => 11,
|
47
|
-
:venue => "Stockholm",
|
48
|
-
:true_field => true,
|
49
|
-
:false_field => false,
|
50
|
-
:nil_field => nil,
|
51
|
-
:ary_field => ["one", 2.0, 3, [{"abc" => 123}]]
|
52
|
-
},
|
53
|
-
:timestamp => @now.to_i,
|
54
|
-
:reply_to => "a.sender",
|
55
|
-
:correlation_id => "r-1",
|
56
|
-
:message_id => "m-1")
|
57
|
-
|
58
|
-
sleep 0.7
|
59
|
-
|
60
|
-
metadata.content_type.should == "application/octet-stream"
|
61
|
-
metadata.priority.should == 8
|
62
|
-
|
63
|
-
time = metadata.headers["time"]
|
64
|
-
time.year.should == @now.year
|
65
|
-
time.month.should == @now.month
|
66
|
-
time.day.should == @now.day
|
67
|
-
time.hour.should == @now.hour
|
68
|
-
time.min.should == @now.min
|
69
|
-
time.sec.should == @now.sec
|
70
|
-
|
71
|
-
metadata.headers["coordinates"]["latitude"].should == 59.35
|
72
|
-
metadata.headers["participants"].should == 11
|
73
|
-
metadata.headers["venue"].should == "Stockholm"
|
74
|
-
metadata.headers["true_field"].should == true
|
75
|
-
metadata.headers["false_field"].should == false
|
76
|
-
metadata.headers["nil_field"].should be_nil
|
77
|
-
metadata.headers["ary_field"].should == ["one", 2.0, 3, [{ "abc" => 123}]]
|
78
|
-
|
79
|
-
metadata.timestamp.should == Time.at(@now.to_i)
|
80
|
-
metadata.type.should == "kinda.checkin"
|
81
|
-
metadata.reply_to.should == "a.sender"
|
82
|
-
metadata.correlation_id.should == "r-1"
|
83
|
-
metadata.message_id.should == "m-1"
|
84
|
-
metadata.app_id.should == "bunny.example"
|
85
|
-
|
86
|
-
envelope.consumer_tag.should_not be_nil
|
87
|
-
envelope.consumer_tag.should_not be_empty
|
88
|
-
envelope.should_not be_redelivered
|
89
|
-
envelope.delivery_tag.should == 1
|
90
|
-
envelope.routing_key.should == queue_name
|
91
|
-
envelope.exchange.should == ""
|
92
|
-
|
93
|
-
ch.close
|
94
|
-
end
|
95
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "amq.* exchanges" 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 "are predeclared" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
|
17
|
-
["amq.fanout", "amq.direct", "amq.topic", "amq.match", "amq.headers"].each do |e|
|
18
|
-
x = ch.exchange(e)
|
19
|
-
x.should be_predeclared
|
20
|
-
end
|
21
|
-
|
22
|
-
ch.close
|
23
|
-
end
|
24
|
-
end
|
@@ -1,77 +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", :continuation_timeout => 10000)
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:n) { 200 }
|
15
|
-
|
16
|
-
context "when publishing with confirms enabled" do
|
17
|
-
it "increments delivery index" do
|
18
|
-
ch = connection.create_channel
|
19
|
-
ch.should_not be_using_publisher_confirmations
|
20
|
-
|
21
|
-
ch.confirm_select
|
22
|
-
ch.should be_using_publisher_confirmations
|
23
|
-
|
24
|
-
q = ch.queue("", :exclusive => true)
|
25
|
-
x = ch.default_exchange
|
26
|
-
|
27
|
-
n.times do
|
28
|
-
x.publish("xyzzy", :routing_key => q.name)
|
29
|
-
end
|
30
|
-
|
31
|
-
ch.next_publish_seq_no.should == n + 1
|
32
|
-
ch.wait_for_confirms.should be_true
|
33
|
-
sleep 0.25
|
34
|
-
|
35
|
-
q.message_count.should == n
|
36
|
-
q.purge
|
37
|
-
|
38
|
-
ch.close
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
context "with a single-threaded connection" do
|
44
|
-
let(:connection) do
|
45
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :continuation_timeout => 10000, :threaded => false)
|
46
|
-
c.start
|
47
|
-
c
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
context "when publishing with confirms enabled" do
|
52
|
-
it "increments delivery index" do
|
53
|
-
ch = connection.create_channel
|
54
|
-
ch.should_not be_using_publisher_confirmations
|
55
|
-
|
56
|
-
ch.confirm_select
|
57
|
-
ch.should be_using_publisher_confirmations
|
58
|
-
|
59
|
-
q = ch.queue("", :exclusive => true)
|
60
|
-
x = ch.default_exchange
|
61
|
-
|
62
|
-
n.times do
|
63
|
-
x.publish("xyzzy", :routing_key => q.name)
|
64
|
-
end
|
65
|
-
|
66
|
-
ch.next_publish_seq_no.should == n + 1
|
67
|
-
ch.wait_for_confirms.should be_true
|
68
|
-
sleep 0.25
|
69
|
-
|
70
|
-
q.message_count.should == n
|
71
|
-
q.purge
|
72
|
-
|
73
|
-
ch.close
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
unless ENV["CI"]
|
4
|
-
describe "Message framing implementation" do
|
5
|
-
let(:connection) do
|
6
|
-
c = Bunny.new(:user => "bunny_gem",
|
7
|
-
:password => "bunny_password",
|
8
|
-
:vhost => "bunny_testbed",
|
9
|
-
:port => ENV.fetch("RABBITMQ_PORT", 5672))
|
10
|
-
c.start
|
11
|
-
c
|
12
|
-
end
|
13
|
-
|
14
|
-
after :each do
|
15
|
-
connection.close if connection.open?
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
context "with payload exceeding 128 Kb (max frame size)" do
|
20
|
-
it "successfully frames the message" do
|
21
|
-
ch = connection.create_channel
|
22
|
-
|
23
|
-
q = ch.queue("", :exclusive => true)
|
24
|
-
x = ch.default_exchange
|
25
|
-
|
26
|
-
as = ("a" * (1024 * 1024 * 4 + 28237777))
|
27
|
-
x.publish(as, :routing_key => q.name, :persistent => true)
|
28
|
-
|
29
|
-
sleep(1)
|
30
|
-
q.message_count.should == 1
|
31
|
-
|
32
|
-
_, _, payload = q.pop
|
33
|
-
payload.bytesize.should == as.bytesize
|
34
|
-
|
35
|
-
ch.close
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
context "with empty message body" do
|
42
|
-
it "successfully publishes the message" do
|
43
|
-
ch = connection.create_channel
|
44
|
-
|
45
|
-
q = ch.queue("", :exclusive => true)
|
46
|
-
x = ch.default_exchange
|
47
|
-
|
48
|
-
x.publish("", :routing_key => q.name, :persistent => false, :mandatory => true)
|
49
|
-
|
50
|
-
sleep(0.5)
|
51
|
-
q.message_count.should == 1
|
52
|
-
|
53
|
-
envelope, headers, payload = q.pop
|
54
|
-
|
55
|
-
payload.should == ""
|
56
|
-
|
57
|
-
headers[:content_type].should == "application/octet-stream"
|
58
|
-
headers[:delivery_mode].should == 1
|
59
|
-
headers[:priority].should == 0
|
60
|
-
|
61
|
-
ch.close
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "A client-named", 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
|
-
it "can be bound to a pre-declared exchange" do
|
11
|
-
ch = connection.create_channel
|
12
|
-
q = ch.queue("bunny.tests.queues.client-named#{rand}", :exclusive => true)
|
13
|
-
q.should_not be_server_named
|
14
|
-
|
15
|
-
q.bind("amq.fanout").should == q
|
16
|
-
|
17
|
-
ch.close
|
18
|
-
end
|
19
|
-
|
20
|
-
it "can be unbound from a pre-declared exchange" do
|
21
|
-
ch = connection.create_channel
|
22
|
-
q = ch.queue("bunny.tests.queues.client-named#{rand}", :exclusive => true)
|
23
|
-
q.should_not be_server_named
|
24
|
-
|
25
|
-
q.bind("amq.fanout")
|
26
|
-
q.unbind("amq.fanout").should == q
|
27
|
-
|
28
|
-
ch.close
|
29
|
-
end
|
30
|
-
|
31
|
-
it "can be bound to a custom exchange" do
|
32
|
-
ch = connection.create_channel
|
33
|
-
q = ch.queue("bunny.tests.queues.client-named#{rand}", :exclusive => true)
|
34
|
-
|
35
|
-
x = ch.fanout("bunny.tests.exchanges.fanout#{rand}")
|
36
|
-
q.bind(x).should == q
|
37
|
-
|
38
|
-
x.delete
|
39
|
-
ch.close
|
40
|
-
end
|
41
|
-
|
42
|
-
it "can be unbound from a custom exchange" do
|
43
|
-
ch = connection.create_channel
|
44
|
-
q = ch.queue("bunny.tests.queues.client-named#{rand}", :exclusive => true)
|
45
|
-
q.should_not be_server_named
|
46
|
-
|
47
|
-
x = ch.fanout("bunny.tests.fanout", :auto_delete => true, :durable => false)
|
48
|
-
|
49
|
-
q.bind(x)
|
50
|
-
q.unbind(x).should == q
|
51
|
-
|
52
|
-
ch.close
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
describe "A server-named", Bunny::Queue do
|
59
|
-
let(:connection) do
|
60
|
-
c = Bunny.new
|
61
|
-
c.start
|
62
|
-
c
|
63
|
-
end
|
64
|
-
|
65
|
-
it "can be bound to a pre-declared exchange" do
|
66
|
-
ch = connection.create_channel
|
67
|
-
q = ch.queue("", :exclusive => true)
|
68
|
-
q.should be_server_named
|
69
|
-
|
70
|
-
q.bind("amq.fanout").should == q
|
71
|
-
|
72
|
-
ch.close
|
73
|
-
end
|
74
|
-
|
75
|
-
it "can be unbound from a pre-declared exchange" do
|
76
|
-
ch = connection.create_channel
|
77
|
-
q = ch.queue("", :exclusive => true)
|
78
|
-
q.should be_server_named
|
79
|
-
|
80
|
-
q.bind("amq.fanout")
|
81
|
-
q.unbind("amq.fanout").should == q
|
82
|
-
|
83
|
-
ch.close
|
84
|
-
end
|
85
|
-
|
86
|
-
it "can be bound to a custom exchange" do
|
87
|
-
ch = connection.create_channel
|
88
|
-
q = ch.queue("", :exclusive => true)
|
89
|
-
|
90
|
-
x = ch.fanout("bunny.tests.exchanges.fanout#{rand}")
|
91
|
-
q.bind(x).should == q
|
92
|
-
|
93
|
-
x.delete
|
94
|
-
ch.close
|
95
|
-
end
|
96
|
-
|
97
|
-
it "can be bound from a custom exchange" do
|
98
|
-
ch = connection.create_channel
|
99
|
-
q = ch.queue("", :exclusive => true)
|
100
|
-
|
101
|
-
name = "bunny.tests.exchanges.fanout#{rand}"
|
102
|
-
x = ch.fanout(name)
|
103
|
-
q.bind(x)
|
104
|
-
q.unbind(name).should == q
|
105
|
-
|
106
|
-
x.delete
|
107
|
-
ch.close
|
108
|
-
end
|
109
|
-
end
|
@@ -1,190 +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
|
-
context "when queue name is specified" do
|
15
|
-
let(:name) { "a queue declared at #{Time.now.to_i}" }
|
16
|
-
|
17
|
-
it "declares a new queue with that name" do
|
18
|
-
ch = connection.create_channel
|
19
|
-
|
20
|
-
q = ch.queue(name)
|
21
|
-
q.name.should == name
|
22
|
-
|
23
|
-
q.delete
|
24
|
-
ch.close
|
25
|
-
end
|
26
|
-
|
27
|
-
it "caches that queue" do
|
28
|
-
ch = connection.create_channel
|
29
|
-
|
30
|
-
q = ch.queue(name)
|
31
|
-
ch.queue(name).object_id.should == q.object_id
|
32
|
-
|
33
|
-
q.delete
|
34
|
-
ch.close
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
context "when queue name is passed on as an empty string" do
|
40
|
-
it "uses server-assigned queue name" do
|
41
|
-
ch = connection.create_channel
|
42
|
-
|
43
|
-
q = ch.queue("")
|
44
|
-
q.name.should_not be_empty
|
45
|
-
q.name.should =~ /^amq.gen.+/
|
46
|
-
q.should be_server_named
|
47
|
-
q.delete
|
48
|
-
|
49
|
-
ch.close
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
context "when queue is declared as durable" do
|
55
|
-
it "declares it as durable" do
|
56
|
-
ch = connection.create_channel
|
57
|
-
|
58
|
-
q = ch.queue("bunny.tests.queues.durable", :durable => true)
|
59
|
-
q.should be_durable
|
60
|
-
q.should_not be_auto_delete
|
61
|
-
q.should_not be_exclusive
|
62
|
-
q.arguments.should be_nil
|
63
|
-
q.delete
|
64
|
-
|
65
|
-
ch.close
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
context "when queue is declared as exclusive" do
|
71
|
-
it "declares it as exclusive" do
|
72
|
-
ch = connection.create_channel
|
73
|
-
|
74
|
-
q = ch.queue("bunny.tests.queues.exclusive", :exclusive => true)
|
75
|
-
q.should be_exclusive
|
76
|
-
q.should_not be_durable
|
77
|
-
q.delete
|
78
|
-
|
79
|
-
ch.close
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
context "when queue is declared as auto-delete" do
|
85
|
-
it "declares it as auto-delete" do
|
86
|
-
ch = connection.create_channel
|
87
|
-
|
88
|
-
q = ch.queue("bunny.tests.queues.auto-delete", :auto_delete => true)
|
89
|
-
q.should be_auto_delete
|
90
|
-
q.should_not be_exclusive
|
91
|
-
q.should_not be_durable
|
92
|
-
q.delete
|
93
|
-
|
94
|
-
ch.close
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
context "when queue is declared with a different set of attributes" do
|
101
|
-
it "raises an exception" do
|
102
|
-
ch = connection.create_channel
|
103
|
-
|
104
|
-
q = ch.queue("bunny.tests.queues.auto-delete", :auto_delete => true, :durable => false)
|
105
|
-
expect {
|
106
|
-
# force re-declaration
|
107
|
-
ch.queue_declare("bunny.tests.queues.auto-delete", :auto_delete => false, :durable => true)
|
108
|
-
}.to raise_error(Bunny::PreconditionFailed)
|
109
|
-
|
110
|
-
ch.should be_closed
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
context "when queue is declared with message TTL" do
|
116
|
-
let(:args) do
|
117
|
-
# in ms
|
118
|
-
{"x-message-ttl" => 1000}
|
119
|
-
end
|
120
|
-
|
121
|
-
it "causes all messages in it to have a TTL" do
|
122
|
-
ch = connection.create_channel
|
123
|
-
|
124
|
-
q = ch.queue("bunny.tests.queues.with-arguments.ttl", :arguments => args, :exclusive => true)
|
125
|
-
q.arguments.should == args
|
126
|
-
|
127
|
-
q.publish("xyzzy")
|
128
|
-
sleep 0.1
|
129
|
-
|
130
|
-
q.message_count.should == 1
|
131
|
-
sleep 1.5
|
132
|
-
q.message_count.should == 0
|
133
|
-
|
134
|
-
ch.close
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
|
-
describe "#queue_exists?" do
|
140
|
-
context "when a queue exists" do
|
141
|
-
it "returns true" do
|
142
|
-
ch = connection.create_channel
|
143
|
-
q = ch.queue("", :exlusive => true)
|
144
|
-
|
145
|
-
connection.queue_exists?(q.name).should be_true
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context "when a queue DOES NOT exist" do
|
150
|
-
it "returns false" do
|
151
|
-
connection.queue_exists?("suf89u9a4jo3ndnakls##{Time.now.to_i}").should be_false
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
unless ENV["CI"]
|
159
|
-
# requires RabbitMQ 3.1+
|
160
|
-
context "when queue is declared with bounded length" do
|
161
|
-
let(:n) { 10 }
|
162
|
-
let(:args) do
|
163
|
-
# in ms
|
164
|
-
{"x-max-length" => n}
|
165
|
-
end
|
166
|
-
|
167
|
-
# see http://www.rabbitmq.com/maxlength.html for more info
|
168
|
-
it "causes the queue to be bounded" do
|
169
|
-
ch = connection.create_channel
|
170
|
-
|
171
|
-
q = ch.queue("bunny.tests.queues.with-arguments.max-length", :arguments => args, :exclusive => true)
|
172
|
-
q.arguments.should == args
|
173
|
-
|
174
|
-
(n * 10).times do
|
175
|
-
q.publish("xyzzy")
|
176
|
-
end
|
177
|
-
|
178
|
-
q.message_count.should == n
|
179
|
-
(n * 5).times do
|
180
|
-
q.publish("xyzzy")
|
181
|
-
end
|
182
|
-
|
183
|
-
q.message_count.should == n
|
184
|
-
q.delete
|
185
|
-
|
186
|
-
ch.close
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Queue, "#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
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
context "with a name of an existing queue" do
|
17
|
-
it "deletes that queue" do
|
18
|
-
ch = connection.create_channel
|
19
|
-
q = ch.queue("")
|
20
|
-
|
21
|
-
q.delete
|
22
|
-
# no exception as of RabbitMQ 3.2. MK.
|
23
|
-
q.delete
|
24
|
-
|
25
|
-
ch.queues.size.should == 0
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
context "with a name of an existing queue" do
|
31
|
-
it "DOES NOT raise an exception" do
|
32
|
-
ch = connection.create_channel
|
33
|
-
|
34
|
-
# no exception as of RabbitMQ 3.2. MK.
|
35
|
-
ch.queue_delete("sdkhflsdjflskdjflsd#{rand}")
|
36
|
-
ch.queue_delete("sdkhflsdjflskdjflsd#{rand}")
|
37
|
-
ch.queue_delete("sdkhflsdjflskdjflsd#{rand}")
|
38
|
-
ch.queue_delete("sdkhflsdjflskdjflsd#{rand}")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,30 +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
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
it "can be purged" do
|
16
|
-
ch = connection.create_channel
|
17
|
-
|
18
|
-
q = ch.queue("", :exclusive => true)
|
19
|
-
x = ch.default_exchange
|
20
|
-
|
21
|
-
x.publish("xyzzy", :routing_key => q.name)
|
22
|
-
sleep(0.5)
|
23
|
-
|
24
|
-
q.message_count.should == 1
|
25
|
-
q.purge
|
26
|
-
q.message_count.should == 0
|
27
|
-
|
28
|
-
ch.close
|
29
|
-
end
|
30
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Queue, "bound to an 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
|
-
it "can be unbound from an exchange it was bound to" do
|
16
|
-
ch = connection.create_channel
|
17
|
-
x = ch.fanout("amq.fanout")
|
18
|
-
q = ch.queue("", :exclusive => true).bind(x)
|
19
|
-
|
20
|
-
x.publish("")
|
21
|
-
sleep 0.3
|
22
|
-
q.message_count.should == 1
|
23
|
-
|
24
|
-
q.unbind(x)
|
25
|
-
|
26
|
-
x.publish("")
|
27
|
-
q.message_count.should == 1
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
describe Bunny::Queue, "NOT bound to an exchange" do
|
34
|
-
let(:connection) do
|
35
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
36
|
-
c.start
|
37
|
-
c
|
38
|
-
end
|
39
|
-
|
40
|
-
after :each do
|
41
|
-
connection.close
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
it "cannot be unbound (raises a channel error)" do
|
46
|
-
ch = connection.create_channel
|
47
|
-
x = ch.fanout("amq.fanout")
|
48
|
-
q = ch.queue("", :exclusive => true)
|
49
|
-
|
50
|
-
# No exception as of RabbitMQ 3.2. MK.
|
51
|
-
q.unbind(x)
|
52
|
-
q.unbind(x)
|
53
|
-
end
|
54
|
-
end
|