bunny 2.19.0 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -32
  3. data/lib/bunny/channel.rb +86 -10
  4. data/lib/bunny/consumer.rb +2 -2
  5. data/lib/bunny/delivery_info.rb +1 -1
  6. data/lib/bunny/queue.rb +33 -2
  7. data/lib/bunny/session.rb +1 -1
  8. data/lib/bunny/transport.rb +30 -1
  9. data/lib/bunny/version.rb +1 -1
  10. data/lib/bunny.rb +45 -4
  11. metadata +4 -144
  12. data/spec/config/enabled_plugins +0 -1
  13. data/spec/config/rabbitmq.conf +0 -13
  14. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  15. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  16. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -357
  17. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  18. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  19. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  20. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  21. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  22. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  23. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  24. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -66
  25. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  26. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -483
  27. data/spec/higher_level_api/integration/connection_spec.rb +0 -589
  28. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  29. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  30. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  31. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  32. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  33. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  34. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  35. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  36. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  37. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  38. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  39. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  40. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  41. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  42. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -285
  43. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  44. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  45. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  46. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  47. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  48. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -255
  49. data/spec/higher_level_api/integration/toxiproxy_spec.rb +0 -76
  50. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  51. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  52. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  53. data/spec/issues/issue100_spec.rb +0 -42
  54. data/spec/issues/issue141_spec.rb +0 -43
  55. data/spec/issues/issue202_spec.rb +0 -15
  56. data/spec/issues/issue224_spec.rb +0 -40
  57. data/spec/issues/issue465_spec.rb +0 -32
  58. data/spec/issues/issue549_spec.rb +0 -30
  59. data/spec/issues/issue609_spec.rb +0 -84
  60. data/spec/issues/issue78_spec.rb +0 -72
  61. data/spec/issues/issue83_spec.rb +0 -30
  62. data/spec/issues/issue97_attachment.json +0 -1
  63. data/spec/issues/issue97_spec.rb +0 -175
  64. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  65. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  66. data/spec/spec_helper.rb +0 -47
  67. data/spec/stress/channel_close_stress_spec.rb +0 -64
  68. data/spec/stress/channel_open_stress_spec.rb +0 -84
  69. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  70. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  71. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  72. data/spec/stress/connection_open_close_spec.rb +0 -52
  73. data/spec/stress/merry_go_round_spec.rb +0 -105
  74. data/spec/toxiproxy_helper.rb +0 -28
  75. data/spec/unit/bunny_spec.rb +0 -15
  76. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  77. data/spec/unit/concurrent/condition_spec.rb +0 -82
  78. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  79. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  80. data/spec/unit/exchange_recovery_spec.rb +0 -39
  81. 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(username: "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
- expect(cancelled).to eq 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
- expect(consumer).to 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
- expect(xs).to eq ["abc"]
124
-
125
- ch.close
126
- end
127
- end
128
- end
@@ -1,75 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "A message" do
4
- let(:connection) do
5
- c = Bunny.new(username: "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(manual_ack: true)
26
- expect(dlq.message_count).to be_zero
27
- ch.nack(delivery_info.delivery_tag)
28
-
29
- sleep 0.2
30
- expect(q.message_count).to be_zero
31
-
32
- delivery, properties, body = dlq.pop
33
- ds = properties.headers["x-death"]
34
- expect(ds).not_to be_empty
35
- expect(ds.first["reason"]).to eq("rejected")
36
-
37
- dlx.delete
38
- end
39
-
40
- it "is considered to be dead-lettered when it expires" do
41
- ch = connection.create_channel
42
- x = ch.fanout("amq.fanout")
43
- dlx = ch.fanout("bunny.tests.dlx.exchange")
44
- q = ch.queue("", exclusive: true, arguments: {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
45
- # dead letter queue
46
- dlq = ch.queue("", exclusive: true).bind(dlx)
47
-
48
- x.publish("")
49
- sleep 0.2
50
-
51
- expect(q.message_count).to be_zero
52
- expect(dlq.message_count).to eq 1
53
-
54
- dlx.delete
55
- end
56
-
57
- it "carries the x-death header" do
58
- ch = connection.create_channel
59
- x = ch.fanout("amq.fanout")
60
- dlx = ch.fanout("bunny.tests.dlx.exchange")
61
- q = ch.queue("", exclusive: true, arguments: {"x-dead-letter-exchange" => dlx.name, "x-message-ttl" => 100}).bind(x)
62
- # dead letter queue
63
- dlq = ch.queue("", exclusive: true).bind(dlx)
64
-
65
- x.publish("")
66
- sleep 0.2
67
-
68
- delivery, properties, body = dlq.pop
69
- ds = properties.headers["x-death"]
70
- expect(ds).not_to be_empty
71
- expect(ds.first["reason"]).to eq("expired")
72
-
73
- dlx.delete
74
- end
75
- end
@@ -1,31 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Exchange do
4
- let(:connection) do
5
- c = Bunny.new(username: "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
- expect(queue.message_count).to be > 0
28
-
29
- ch.close
30
- end
31
- end
@@ -1,237 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Exchange do
4
- let(:connection) do
5
- c = Bunny.new(username: "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
- context "of default type" do
15
- it "is declared with an empty name" do
16
- ch = connection.create_channel
17
-
18
- x = Bunny::Exchange.default(ch)
19
-
20
- expect(x.name).to eq ''
21
- end
22
- end
23
-
24
- context "of type fanout" do
25
- context "with a non-predefined name" do
26
- it "is declared" do
27
- ch = connection.create_channel
28
-
29
- name = "bunny.tests.exchanges.fanout#{rand}"
30
- x = ch.fanout(name)
31
- expect(x.name).to eq name
32
-
33
- x.delete
34
- ch.close
35
- end
36
- end
37
-
38
- context "with a predefined name" do
39
- it "is NOT declared" do
40
- ch = connection.create_channel
41
-
42
- name = "amq.fanout"
43
- x = ch.fanout(name)
44
- expect(x.name).to eq name
45
-
46
- ch.close
47
- end
48
- end
49
-
50
- context "with a name prefixed with 'amq.'" do
51
- it "raises an exception" do
52
- ch = connection.create_channel
53
-
54
- expect {
55
- ch.fanout("amq.test")
56
- }.to raise_error(Bunny::AccessRefused)
57
-
58
- expect(ch).to be_closed
59
- expect {
60
- ch.fanout("amq.test")
61
- }.to raise_error(Bunny::ChannelAlreadyClosed)
62
- end
63
- end
64
-
65
- context "with the durable property" do
66
- it "is declared as durable" do
67
- ch = connection.create_channel
68
-
69
- name = "bunny.tests.exchanges.durable"
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
-
75
- x.delete
76
- ch.close
77
- end
78
- end
79
-
80
-
81
- context "with the auto-delete property" do
82
- it "is declared as auto-delete" do
83
- ch = connection.create_channel
84
-
85
- name = "bunny.tests.exchanges.auto-delete"
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
-
91
- ch.exchange(name, type: :fanout, auto_delete: true)
92
-
93
- x.delete
94
- ch.close
95
- end
96
- end
97
-
98
-
99
- context "when declared with a different set of attributes" do
100
- it "raises an exception" do
101
- ch1 = connection.create_channel
102
- ch2 = connection.create_channel
103
-
104
- x = ch1.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
105
- expect {
106
- # force re-declaration
107
- ch2.exchange_declare("bunny.tests.exchanges.fanout", :direct, auto_delete: false, durable: true)
108
- }.to raise_error(Bunny::PreconditionFailed)
109
-
110
- expect(ch2).to be_closed
111
- expect {
112
- ch2.fanout("bunny.tests.exchanges.fanout", auto_delete: true, durable: false)
113
- }.to raise_error(Bunny::ChannelAlreadyClosed)
114
- end
115
- end
116
- end
117
-
118
- context "of type direct" do
119
- context "with a non-predefined name" do
120
- it "is declared" do
121
- ch = connection.create_channel
122
-
123
- name = "bunny.tests.exchanges.direct"
124
- x = ch.direct(name)
125
- expect(x.name).to eq name
126
-
127
- ch.exchange(name, type: :direct)
128
-
129
- x.delete
130
- ch.close
131
- end
132
- end
133
-
134
- context "with a predefined name" do
135
- it "is NOT declared" do
136
- ch = connection.create_channel
137
-
138
- name = "amq.direct"
139
- x = ch.direct(name)
140
- expect(x.name).to eq name
141
-
142
- ch.close
143
- end
144
- end
145
- end
146
-
147
- context "of type topic" do
148
- context "with a non-predefined name" do
149
- it "is declared" do
150
- ch = connection.create_channel
151
-
152
- name = "bunny.tests.exchanges.topic"
153
- x = ch.topic(name)
154
- expect(x.name).to eq name
155
-
156
- ch.exchange(name, type: :topic)
157
-
158
- x.delete
159
- ch.close
160
- end
161
- end
162
-
163
- context "with a predefined name" do
164
- it "is NOT declared" do
165
- ch = connection.create_channel
166
-
167
- name = "amq.topic"
168
- x = ch.topic(name)
169
- expect(x.name).to eq name
170
-
171
- ch.close
172
- end
173
- end
174
- end
175
-
176
- context "of type headers" do
177
- context "with a non-predefined name" do
178
- it "is declared" do
179
- ch = connection.create_channel
180
-
181
- name = "bunny.tests.exchanges.headers"
182
- x = ch.headers(name)
183
- expect(x.name).to eq name
184
-
185
- x.delete
186
- ch.close
187
- end
188
- end
189
-
190
- context "with a predefined name (amq.match)" do
191
- it "is NOT declared" do
192
- ch = connection.create_channel
193
-
194
- name = "amq.match"
195
- x = ch.headers(name)
196
- expect(x.name).to eq name
197
-
198
- ch.close
199
- end
200
- end
201
-
202
- context "with a predefined name (amq.headers)" do
203
- it "is NOT declared" do
204
- ch = connection.create_channel
205
-
206
- name = "amq.headers"
207
- x = ch.headers(name)
208
- expect(x.name).to eq name
209
-
210
- ch.close
211
- end
212
- end
213
- end
214
-
215
-
216
- context "that is internal" do
217
- it "can be declared" do
218
- ch = connection.create_channel
219
- x = ch.fanout("bunny.tests.exchanges.internal", internal: true)
220
- expect(x).to be_internal
221
- x.delete
222
-
223
- ch.close
224
- end
225
- end
226
-
227
- context "not declared as internal" do
228
- it "is not internal" do
229
- ch = connection.create_channel
230
- x = ch.fanout("bunny.tests.exchanges.non-internal")
231
- expect(x).not_to be_internal
232
- x.delete
233
-
234
- ch.close
235
- end
236
- end
237
- end
@@ -1,105 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Exchange, "#delete" do
4
- let(:connection) do
5
- c = Bunny.new(username: "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
- expect(ch.exchanges.size).to eq 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
- expect(x.delete).to eq 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
- expect(x.delete).to eq 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
- expect(x.delete).to eq 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
- expect(x.delete).to eq 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
- expect(x.delete).to eq 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
- expect(connection.exchange_exists?("amq.fanout")).to eq true
93
- expect(connection.exchange_exists?("amq.direct")).to eq true
94
- expect(connection.exchange_exists?("amq.topic")).to eq true
95
- expect(connection.exchange_exists?("amq.match")).to eq true
96
- end
97
- end
98
-
99
- context "when a exchange DOES NOT exist" do
100
- it "returns false" do
101
- expect(connection.exchange_exists?("suf89u9a4jo3ndnakls##{Time.now.to_i}")).to eq 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(username: "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
- expect(queue.message_count).to eq 1
28
- queue.pop(manual_ack: true)
29
-
30
- destination.unbind(source)
31
- source.publish("")
32
- sleep 0.5
33
-
34
- expect(queue.message_count).to eq 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(username: "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,49 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Client-defined heartbeat interval" do
4
- context "with value > 0" do
5
- let(:connection) do
6
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed", heartbeat_timeout: 4)
7
- c.start
8
- c
9
- end
10
-
11
- it "can be enabled explicitly" do
12
- sleep 5.0
13
-
14
- connection.close
15
- end
16
- end
17
-
18
- # issue 267
19
- context "with value = 0" do
20
- let(:connection) do
21
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
22
- heartbeat_timeout: 0, automatically_recover: false)
23
- c.start
24
- c
25
- end
26
-
27
- it "disables heartbeats" do
28
- sleep 1.0
29
-
30
- connection.close
31
- end
32
- end
33
- end
34
-
35
-
36
- describe "Server-defined heartbeat interval" do
37
- let(:connection) do
38
- c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed", heartbeat_timeout: :server)
39
- c.start
40
- c
41
- end
42
-
43
- it "can be enabled explicitly" do
44
- puts "Sleeping for 5 seconds with heartbeat interval of 4"
45
- sleep 5.0
46
-
47
- connection.close
48
- end
49
- end