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.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +92 -87
  3. data/lib/amq/protocol/extensions.rb +2 -0
  4. data/lib/bunny/authentication/credentials_encoder.rb +2 -0
  5. data/lib/bunny/authentication/external_mechanism_encoder.rb +2 -0
  6. data/lib/bunny/authentication/plain_mechanism_encoder.rb +2 -0
  7. data/lib/bunny/channel.rb +485 -186
  8. data/lib/bunny/channel_id_allocator.rb +8 -4
  9. data/lib/bunny/concurrent/atomic_fixnum.rb +2 -0
  10. data/lib/bunny/concurrent/condition.rb +2 -0
  11. data/lib/bunny/concurrent/continuation_queue.rb +37 -13
  12. data/lib/bunny/concurrent/synchronized_sorted_set.rb +2 -0
  13. data/lib/bunny/consumer.rb +20 -13
  14. data/lib/bunny/consumer_tag_generator.rb +6 -2
  15. data/lib/bunny/consumer_work_pool.rb +37 -7
  16. data/lib/bunny/cruby/socket.rb +51 -22
  17. data/lib/bunny/cruby/ssl_socket.rb +68 -5
  18. data/lib/bunny/delivery_info.rb +3 -1
  19. data/lib/bunny/exceptions.rb +27 -4
  20. data/lib/bunny/exchange.rb +35 -29
  21. data/lib/bunny/framing.rb +2 -0
  22. data/lib/bunny/get_response.rb +85 -0
  23. data/lib/bunny/heartbeat_sender.rb +9 -6
  24. data/lib/bunny/message_properties.rb +2 -0
  25. data/lib/bunny/queue.rb +89 -41
  26. data/lib/bunny/reader_loop.rb +72 -28
  27. data/lib/bunny/return_info.rb +2 -0
  28. data/lib/bunny/session.rb +621 -225
  29. data/lib/bunny/socket.rb +7 -12
  30. data/lib/bunny/ssl_socket.rb +7 -12
  31. data/lib/bunny/test_kit.rb +15 -0
  32. data/lib/bunny/timeout.rb +3 -12
  33. data/lib/bunny/timestamp.rb +24 -0
  34. data/lib/bunny/transport.rb +223 -98
  35. data/lib/bunny/version.rb +2 -1
  36. data/lib/bunny/versioned_delivery_tag.rb +2 -0
  37. data/lib/bunny.rb +54 -8
  38. metadata +38 -224
  39. data/.gitignore +0 -22
  40. data/.rspec +0 -3
  41. data/.ruby-version +0 -1
  42. data/.travis.yml +0 -23
  43. data/.yardopts +0 -8
  44. data/ChangeLog.md +0 -1092
  45. data/Gemfile +0 -54
  46. data/LICENSE +0 -21
  47. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  48. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  49. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  50. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  51. data/benchmarks/channel_open.rb +0 -28
  52. data/benchmarks/mutex_and_monitor.rb +0 -42
  53. data/benchmarks/queue_declare.rb +0 -29
  54. data/benchmarks/queue_declare_and_bind.rb +0 -29
  55. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  56. data/benchmarks/synchronized_sorted_set.rb +0 -53
  57. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  58. data/bin/ci/before_build.sh +0 -31
  59. data/bunny.gemspec +0 -40
  60. data/examples/connection/authentication_failure.rb +0 -16
  61. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  62. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  63. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  64. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  65. data/examples/connection/channel_level_exception.rb +0 -35
  66. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  67. data/examples/connection/heartbeat.rb +0 -17
  68. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  69. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  70. data/examples/connection/unknown_host.rb +0 -16
  71. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  72. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  73. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  74. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  75. data/examples/guides/extensions/alternate_exchange.rb +0 -28
  76. data/examples/guides/extensions/basic_nack.rb +0 -33
  77. data/examples/guides/extensions/connection_blocked.rb +0 -35
  78. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  79. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  80. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  81. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  82. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  83. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  84. data/examples/guides/extensions/queue_lease.rb +0 -26
  85. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  86. data/examples/guides/getting_started/blabbr.rb +0 -27
  87. data/examples/guides/getting_started/hello_world.rb +0 -20
  88. data/examples/guides/getting_started/weathr.rb +0 -47
  89. data/examples/guides/queues/one_off_consumer.rb +0 -23
  90. data/examples/guides/queues/redeliveries.rb +0 -79
  91. data/lib/bunny/compatibility.rb +0 -24
  92. data/lib/bunny/concurrent/linked_continuation_queue.rb +0 -61
  93. data/lib/bunny/jruby/socket.rb +0 -40
  94. data/lib/bunny/jruby/ssl_socket.rb +0 -53
  95. data/lib/bunny/system_timer.rb +0 -20
  96. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  97. data/repl +0 -3
  98. data/spec/compatibility/queue_declare_spec.rb +0 -44
  99. data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
  100. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -71
  101. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -76
  102. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -225
  103. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  104. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -48
  105. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -79
  106. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -89
  107. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -29
  108. data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
  109. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -74
  110. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  111. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
  112. data/spec/higher_level_api/integration/channel_flow_spec.rb +0 -21
  113. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  114. data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
  115. data/spec/higher_level_api/integration/connection_spec.rb +0 -400
  116. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
  117. data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
  118. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  119. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -52
  120. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  121. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -204
  122. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  123. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  124. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  125. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -31
  126. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  127. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  128. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  129. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -77
  130. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -65
  131. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  132. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -190
  133. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  134. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  135. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  136. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  137. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  138. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -127
  139. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  140. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  141. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  142. data/spec/issues/issue100_spec.rb +0 -42
  143. data/spec/issues/issue141_spec.rb +0 -44
  144. data/spec/issues/issue78_spec.rb +0 -75
  145. data/spec/issues/issue83_spec.rb +0 -31
  146. data/spec/issues/issue97_attachment.json +0 -1
  147. data/spec/issues/issue97_spec.rb +0 -176
  148. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -69
  149. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -100
  150. data/spec/spec_helper.rb +0 -64
  151. data/spec/stress/channel_open_stress_spec.rb +0 -51
  152. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  153. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -69
  154. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -57
  155. data/spec/stress/connection_open_close_spec.rb +0 -40
  156. data/spec/stress/long_running_consumer_spec.rb +0 -83
  157. data/spec/tls/cacert.pem +0 -18
  158. data/spec/tls/client_cert.pem +0 -18
  159. data/spec/tls/client_key.pem +0 -27
  160. data/spec/tls/server_cert.pem +0 -18
  161. data/spec/tls/server_key.pem +0 -27
  162. data/spec/unit/bunny_spec.rb +0 -15
  163. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  164. data/spec/unit/concurrent/condition_spec.rb +0 -82
  165. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  166. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  167. data/spec/unit/system_timer_spec.rb +0 -10
  168. data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,60 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Queue, "#subscribe" do
4
- let(:publisher_connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
6
- c.start
7
- c
8
- end
9
-
10
- let(:consumer_connection) do
11
- c = Bunny.new(:user => "bunny_reader", :password => "reader_password", :vhost => "bunny_testbed")
12
- c.start
13
- c
14
- end
15
-
16
- after :each do
17
- publisher_connection.close if publisher_connection.open?
18
- consumer_connection.close if consumer_connection.open?
19
- end
20
-
21
- context "with automatic acknowledgement mode" do
22
- let(:queue_name) { "bunny.basic_consume#{rand}" }
23
-
24
- it "registers the consumer" do
25
- delivered_keys = []
26
- delivered_data = []
27
-
28
- ch = publisher_connection.create_channel
29
- # declare the queue because the read-only user won't be able to issue
30
- # queue.declare
31
- q = ch.queue(queue_name, :auto_delete => true, :durable => false)
32
-
33
- t = Thread.new do
34
- # give the main thread a bit of time to declare the queue
35
- sleep 0.5
36
- ch = consumer_connection.create_channel
37
- # this connection is read only, use passive declare to only get
38
- # a reference to the queue
39
- q = ch.queue(queue_name, :auto_delete => true, :durable => false, :passive => true)
40
- q.subscribe(:exclusive => false) do |delivery_info, properties, payload|
41
- delivered_keys << delivery_info.routing_key
42
- delivered_data << payload
43
- end
44
- end
45
- t.abort_on_exception = true
46
- sleep 0.5
47
-
48
- x = ch.default_exchange
49
- x.publish("hello", :routing_key => queue_name)
50
-
51
- sleep 0.7
52
- delivered_keys.should include(queue_name)
53
- delivered_data.should include("hello")
54
-
55
- ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0
56
-
57
- ch.close
58
- end
59
- end
60
- end # describe
@@ -1,36 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Sender-selected distribution" 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 "lets publishers specify additional routing keys using CC and BCC headers" do
15
- ch = connection.create_channel
16
- x = ch.direct("bunny.tests.ssd.exchange")
17
- q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "one")
18
- q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "two")
19
- q3 = ch.queue("", :exclusive => true).bind(x, :routing_key => "three")
20
- q4 = ch.queue("", :exclusive => true).bind(x, :routing_key => "four")
21
-
22
- n = 10
23
- n.times do |i|
24
- x.publish("Message #{i}", :routing_key => "one", :headers => {"CC" => ["two", "three"]})
25
- end
26
-
27
- sleep 0.5
28
-
29
- q1.message_count.should == n
30
- q2.message_count.should == n
31
- q3.message_count.should == n
32
- q4.message_count.should be_zero
33
-
34
- x.delete
35
- end
36
- end
@@ -1,127 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "spec_helper"
3
-
4
- unless ENV["CI"]
5
- shared_examples_for "successful TLS connection" do
6
- it "succeeds" do
7
- connection.should be_tls
8
- ch = connection.create_channel
9
-
10
- q = ch.queue("", :exclusive => true)
11
- x = ch.default_exchange
12
-
13
- x.publish("xyzzy", :routing_key => q.name).
14
- publish("xyzzy", :routing_key => q.name).
15
- publish("xyzzy", :routing_key => q.name).
16
- publish("xyzzy", :routing_key => q.name)
17
-
18
- sleep 0.5
19
- q.message_count.should == 4
20
-
21
- i = 0
22
- q.subscribe do |delivery_info, _, payload|
23
- i += 1
24
- end
25
- sleep 1.0
26
- i.should == 4
27
- q.message_count.should == 0
28
-
29
- ch.close
30
- end
31
- end
32
-
33
-
34
- describe "TLS connection to RabbitMQ with client certificates" do
35
- let(:connection) do
36
- c = Bunny.new(:user => "bunny_gem",
37
- :password => "bunny_password",
38
- :vhost => "bunny_testbed",
39
- :tls => true,
40
- :tls_cert => "spec/tls/client_cert.pem",
41
- :tls_key => "spec/tls/client_key.pem",
42
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
43
- c.start
44
- c
45
- end
46
-
47
- after :each do
48
- connection.close
49
- end
50
-
51
- include_examples "successful TLS connection"
52
- end
53
-
54
-
55
- describe "TLS connection to RabbitMQ without client certificates" do
56
- let(:connection) do
57
- c = Bunny.new(:user => "bunny_gem",
58
- :password => "bunny_password",
59
- :vhost => "bunny_testbed",
60
- :tls => true,
61
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
62
- c.start
63
- c
64
- end
65
-
66
- after :each do
67
- connection.close
68
- end
69
-
70
- include_examples "successful TLS connection"
71
- end
72
-
73
-
74
- describe "TLS connection to RabbitMQ with a connection string" do
75
- let(:connection) do
76
- c = Bunny.new("amqps://bunny_gem:bunny_password@127.0.0.1/bunny_testbed",
77
- :tls_cert => "spec/tls/client_cert.pem",
78
- :tls_key => "spec/tls/client_key.pem",
79
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
80
- c.start
81
- c
82
- end
83
-
84
- after :each do
85
- connection.close
86
- end
87
-
88
- include_examples "successful TLS connection"
89
- end
90
-
91
-
92
- describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key" do
93
- let(:connection) do
94
- c = Bunny.new("amqps://bunny_gem:bunny_password@127.0.0.1/bunny_testbed",
95
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
96
- c.start
97
- c
98
- end
99
-
100
- after :each do
101
- connection.close
102
- end
103
-
104
- include_examples "successful TLS connection"
105
- end
106
-
107
-
108
- describe "TLS connection to RabbitMQ with client certificates provided inline" do
109
- let(:connection) do
110
- c = Bunny.new(:user => "bunny_gem",
111
- :password => "bunny_password",
112
- :vhost => "bunny_testbed",
113
- :tls => true,
114
- :tls_cert => File.read("./spec/tls/client_cert.pem"),
115
- :tls_key => File.read("./spec/tls/client_key.pem"),
116
- :tls_ca_certificates => ["./spec/tls/cacert.pem"])
117
- c.start
118
- c
119
- end
120
-
121
- after :each do
122
- connection.close
123
- end
124
-
125
- include_examples "successful TLS connection"
126
- end
127
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#tx_commit" 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 supported" do
15
- ch = connection.create_channel
16
- ch.tx_select
17
- ch.tx_commit
18
-
19
- ch.close
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#tx_rollback" 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 supported" do
15
- ch = connection.create_channel
16
- ch.tx_select
17
- ch.tx_rollback
18
-
19
- ch.close
20
- end
21
- end
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#with_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
- it "closes if the block throws an exception" do
15
- ch = nil
16
- begin
17
- connection.with_channel do |wch|
18
- ch = wch
19
- raise Exception.new
20
- end
21
- rescue Exception
22
- end
23
- ch.should be_closed
24
- end
25
- end
@@ -1,42 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless ENV["CI"]
4
- describe Bunny::Channel, "#basic_publish" do
5
- let(:connection) do
6
- c = Bunny.new(:user => "bunny_gem",
7
- :password => "bunny_password",
8
- :vhost => "bunny_testbed",
9
- :socket_timeout => 0)
10
- c.start
11
- c
12
- end
13
-
14
- after :all do
15
- connection.close if connection.open?
16
- end
17
-
18
-
19
- context "when publishing thousands of messages" do
20
- let(:n) { 2_000 }
21
- let(:m) { 10 }
22
-
23
- it "successfully publishers them all" do
24
- ch = connection.create_channel
25
-
26
- q = ch.queue("", :exclusive => true)
27
- x = ch.default_exchange
28
-
29
- body = "x" * 1024
30
- m.times do |i|
31
- n.times do
32
- x.publish(body, :routing_key => q.name)
33
- end
34
- puts "Published #{i * n} 1K messages..."
35
- end
36
-
37
- q.purge
38
- ch.close
39
- end
40
- end
41
- end
42
- end
@@ -1,44 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Registering 2nd exclusive consumer on 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
-
15
- it "raises a meaningful exception" do
16
- xs = []
17
-
18
- ch1 = connection.create_channel
19
- ch2 = connection.create_channel
20
- q1 = ch1.queue("", :auto_delete => true)
21
- q2 = ch2.queue(q1.name, :auto_delete => true, :passive => true)
22
-
23
- c1 = q1.subscribe(:exclusive => true) do |_, _, payload|
24
- xs << payload
25
- end
26
- sleep 0.1
27
-
28
- lambda do
29
- q2.subscribe(:exclusive => true) do |_, _, _|
30
- end
31
- end.should raise_error(Bunny::AccessRefused)
32
-
33
- ch1.should be_open
34
- ch2.should be_closed
35
-
36
- q1.publish("abc")
37
- sleep 0.1
38
-
39
- # verify that the first consumer is fine
40
- xs.should == ["abc"]
41
-
42
- q1.delete
43
- end
44
- end
@@ -1,75 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless ENV["CI"]
4
- describe Bunny::Queue, "#subscribe" do
5
- let(:connection1) do
6
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
7
- c.start
8
- c
9
- end
10
- let(:connection2) do
11
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
12
- c.start
13
- c
14
- end
15
-
16
- after :all do
17
- connection1.close if connection1.open?
18
- connection2.close if connection2.open?
19
- end
20
-
21
-
22
- context "with an empty queue" do
23
- it "consumes messages" do
24
- delivered_data = []
25
-
26
- ch1 = connection1.create_channel
27
- ch2 = connection1.create_channel
28
-
29
- q = ch1.queue("", :exclusive => true)
30
- q.subscribe(:ack => false, :block => false) do |delivery_info, properties, payload|
31
- delivered_data << payload
32
- end
33
- sleep 0.5
34
-
35
- x = ch2.default_exchange
36
- x.publish("abc", :routing_key => q.name)
37
- sleep 0.7
38
-
39
- delivered_data.should == ["abc"]
40
-
41
- ch1.close
42
- ch2.close
43
- end
44
- end
45
-
46
- context "with a non-empty queue" do
47
- let(:queue_name) { "queue#{rand}" }
48
-
49
- it "consumes messages" do
50
- delivered_data = []
51
-
52
- ch1 = connection1.create_channel
53
- ch2 = connection1.create_channel
54
-
55
- q = ch1.queue(queue_name, :exclusive => true)
56
- x = ch2.default_exchange
57
- 3.times do |i|
58
- x.publish("data#{i}", :routing_key => queue_name)
59
- end
60
- sleep 0.7
61
- q.message_count.should == 3
62
-
63
- q.subscribe(:ack => false, :block => false) do |delivery_info, properties, payload|
64
- delivered_data << payload
65
- end
66
- sleep 0.7
67
-
68
- delivered_data.should == ["data0", "data1", "data2"]
69
-
70
- ch1.close
71
- ch2.close
72
- end
73
- end
74
- end
75
- end
@@ -1,31 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#open" 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 :all do
11
- connection.close if connection.open?
12
- end
13
-
14
-
15
- it "properly resets channel exception state" do
16
- ch = connection.create_channel
17
-
18
- begin
19
- ch.queue("bunny.tests.does.not.exist", :passive => true)
20
- rescue Bunny::NotFound
21
- # expected
22
- end
23
-
24
- # reopen the channel
25
- ch.open
26
-
27
- # should not raise
28
- q = ch.queue("bunny.tests.my.queue")
29
- q.delete
30
- end
31
- end