bunny 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/ChangeLog.md +23 -2
- data/Gemfile +3 -3
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/bunny/channel.rb +1 -1
- data/lib/bunny/channel_id_allocator.rb +3 -3
- data/lib/bunny/concurrent/continuation_queue.rb +9 -5
- data/lib/bunny/exceptions.rb +6 -0
- data/lib/bunny/session.rb +69 -11
- data/lib/bunny/transport.rb +1 -1
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_ack_spec.rb +46 -46
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +13 -13
- data/spec/higher_level_api/integration/basic_consume_spec.rb +40 -40
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +5 -5
- data/spec/higher_level_api/integration/basic_get_spec.rb +5 -5
- data/spec/higher_level_api/integration/basic_nack_spec.rb +13 -13
- data/spec/higher_level_api/integration/basic_publish_spec.rb +7 -7
- data/spec/higher_level_api/integration/basic_qos_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_reject_spec.rb +23 -23
- data/spec/higher_level_api/integration/basic_return_spec.rb +3 -3
- data/spec/higher_level_api/integration/channel_close_spec.rb +1 -1
- data/spec/higher_level_api/integration/channel_open_spec.rb +1 -1
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +93 -55
- data/spec/higher_level_api/integration/connection_spec.rb +46 -46
- data/spec/higher_level_api/integration/connection_stop_spec.rb +9 -8
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +14 -14
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +8 -8
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +4 -4
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +10 -10
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +3 -3
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +5 -5
- data/spec/higher_level_api/integration/heartbeat_spec.rb +4 -4
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +10 -10
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +22 -22
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +8 -8
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +10 -10
- data/spec/higher_level_api/integration/queue_bind_spec.rb +10 -10
- data/spec/higher_level_api/integration/queue_declare_spec.rb +14 -11
- data/spec/higher_level_api/integration/queue_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_purge_spec.rb +3 -3
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +4 -4
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +7 -7
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +6 -6
- data/spec/higher_level_api/integration/tls_connection_spec.rb +40 -40
- data/spec/higher_level_api/integration/tx_commit_spec.rb +1 -1
- data/spec/higher_level_api/integration/tx_rollback_spec.rb +1 -1
- data/spec/higher_level_api/integration/with_channel_spec.rb +1 -1
- data/spec/issues/issue100_spec.rb +7 -7
- data/spec/issues/issue141_spec.rb +3 -3
- data/spec/issues/issue224_spec.rb +3 -3
- data/spec/issues/issue465_spec.rb +32 -0
- data/spec/issues/issue78_spec.rb +11 -10
- data/spec/issues/issue83_spec.rb +1 -1
- data/spec/issues/issue97_spec.rb +20 -20
- data/spec/stress/channel_close_stress_spec.rb +3 -3
- data/spec/stress/channel_open_stress_spec.rb +3 -3
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +2 -1
- data/spec/stress/concurrent_consumers_stress_spec.rb +6 -6
- data/spec/stress/concurrent_publishers_stress_spec.rb +2 -1
- data/spec/stress/connection_open_close_spec.rb +3 -3
- data/spec/stress/long_running_consumer_spec.rb +7 -5
- data/spec/unit/concurrent/condition_spec.rb +5 -5
- metadata +4 -6
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -59
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Consumer, "#cancel" do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -19,8 +19,8 @@ describe Bunny::Consumer, "#cancel" do
|
|
19
19
|
|
20
20
|
t = Thread.new do
|
21
21
|
ch = connection.create_channel
|
22
|
-
q = ch.queue(queue_name, :
|
23
|
-
consumer = q.subscribe(:
|
22
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
23
|
+
consumer = q.subscribe(block: false) do |_, _, payload|
|
24
24
|
delivered_data << payload
|
25
25
|
end
|
26
26
|
|
@@ -34,7 +34,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
34
34
|
sleep 0.5
|
35
35
|
|
36
36
|
ch = connection.create_channel
|
37
|
-
ch.default_exchange.publish("", :
|
37
|
+
ch.default_exchange.publish("", routing_key: queue_name)
|
38
38
|
|
39
39
|
sleep 0.7
|
40
40
|
expect(delivered_data).to be_empty
|
@@ -51,14 +51,14 @@ describe Bunny::Consumer, "#cancel" do
|
|
51
51
|
|
52
52
|
t = Thread.new do
|
53
53
|
ch = connection.create_channel
|
54
|
-
q = ch.queue(queue_name, :
|
54
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
55
55
|
|
56
56
|
consumer = Bunny::Consumer.new(ch, q)
|
57
57
|
consumer.on_delivery do |_, _, payload|
|
58
58
|
delivered_data << payload
|
59
59
|
end
|
60
60
|
|
61
|
-
q.subscribe_with(consumer, :
|
61
|
+
q.subscribe_with(consumer, block: false)
|
62
62
|
end
|
63
63
|
t.abort_on_exception = true
|
64
64
|
sleep 1.0
|
@@ -67,7 +67,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
67
67
|
sleep 1.0
|
68
68
|
|
69
69
|
ch = connection.create_channel
|
70
|
-
ch.default_exchange.publish("", :
|
70
|
+
ch.default_exchange.publish("", routing_key: queue_name)
|
71
71
|
|
72
72
|
sleep 0.7
|
73
73
|
expect(delivered_data).to be_empty
|
@@ -83,7 +83,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
83
83
|
|
84
84
|
t = Thread.new do
|
85
85
|
ch = connection.create_channel(nil, 1, false, 5)
|
86
|
-
q = ch.queue(queue_name, :
|
86
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
87
87
|
|
88
88
|
consumer = Bunny::Consumer.new(ch, q)
|
89
89
|
consumer.on_delivery do |_, _, payload|
|
@@ -91,14 +91,14 @@ describe Bunny::Consumer, "#cancel" do
|
|
91
91
|
delivered_data << payload
|
92
92
|
end
|
93
93
|
|
94
|
-
q.subscribe_with(consumer, :
|
94
|
+
q.subscribe_with(consumer, block: false)
|
95
95
|
end
|
96
96
|
t.abort_on_exception = true
|
97
97
|
sleep 1.0
|
98
98
|
|
99
99
|
ch = connection.create_channel
|
100
100
|
ch.confirm_select
|
101
|
-
ch.default_exchange.publish("", :
|
101
|
+
ch.default_exchange.publish("", routing_key: queue_name)
|
102
102
|
ch.wait_for_confirms
|
103
103
|
sleep 0.5
|
104
104
|
|
@@ -114,7 +114,7 @@ describe Bunny::Consumer, "#cancel" do
|
|
114
114
|
|
115
115
|
t = Thread.new do
|
116
116
|
ch = connection.create_channel(nil, 1, false, 1)
|
117
|
-
q = ch.queue(queue_name, :
|
117
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
118
118
|
|
119
119
|
consumer = Bunny::Consumer.new(ch, q)
|
120
120
|
consumer.on_delivery do |_, _, payload|
|
@@ -122,14 +122,14 @@ describe Bunny::Consumer, "#cancel" do
|
|
122
122
|
delivered_data << payload
|
123
123
|
end
|
124
124
|
|
125
|
-
q.subscribe_with(consumer, :
|
125
|
+
q.subscribe_with(consumer, block: false)
|
126
126
|
end
|
127
127
|
t.abort_on_exception = true
|
128
128
|
sleep 1.0
|
129
129
|
|
130
130
|
ch = connection.create_channel
|
131
131
|
ch.confirm_select
|
132
|
-
ch.default_exchange.publish("", :
|
132
|
+
ch.default_exchange.publish("", routing_key: queue_name)
|
133
133
|
ch.wait_for_confirms
|
134
134
|
sleep 0.5
|
135
135
|
|
@@ -3,7 +3,7 @@ require "set"
|
|
3
3
|
|
4
4
|
describe Bunny::Queue, "#subscribe" do
|
5
5
|
let(:connection) do
|
6
|
-
c = Bunny.new(:
|
6
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
7
7
|
c.start
|
8
8
|
c
|
9
9
|
end
|
@@ -21,8 +21,8 @@ describe Bunny::Queue, "#subscribe" do
|
|
21
21
|
|
22
22
|
t = Thread.new do
|
23
23
|
ch = connection.create_channel
|
24
|
-
q = ch.queue(queue_name, :
|
25
|
-
q.subscribe(:
|
24
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
25
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
26
26
|
delivered_keys << delivery_info.routing_key
|
27
27
|
delivered_data << payload
|
28
28
|
end
|
@@ -32,13 +32,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
32
32
|
|
33
33
|
ch = connection.create_channel
|
34
34
|
x = ch.default_exchange
|
35
|
-
x.publish("hello", :
|
35
|
+
x.publish("hello", routing_key: queue_name)
|
36
36
|
|
37
37
|
sleep 0.7
|
38
38
|
expect(delivered_keys).to include(queue_name)
|
39
39
|
expect(delivered_data).to include("hello")
|
40
40
|
|
41
|
-
expect(ch.queue(queue_name, :
|
41
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
42
42
|
|
43
43
|
ch.close
|
44
44
|
end
|
@@ -50,8 +50,8 @@ describe Bunny::Queue, "#subscribe" do
|
|
50
50
|
delivery_tags = SortedSet.new
|
51
51
|
|
52
52
|
cch = connection.create_channel
|
53
|
-
q = cch.queue(queue_name, :
|
54
|
-
q.subscribe(:
|
53
|
+
q = cch.queue(queue_name, auto_delete: true, durable: false)
|
54
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
55
55
|
delivery_tags << delivery_info.delivery_tag
|
56
56
|
end
|
57
57
|
sleep 0.5
|
@@ -59,13 +59,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
59
59
|
ch = connection.create_channel
|
60
60
|
x = ch.default_exchange
|
61
61
|
100.times do
|
62
|
-
x.publish("hello", :
|
62
|
+
x.publish("hello", routing_key: queue_name)
|
63
63
|
end
|
64
64
|
|
65
65
|
sleep 1.0
|
66
66
|
expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
|
67
67
|
|
68
|
-
expect(ch.queue(queue_name, :
|
68
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
69
69
|
|
70
70
|
ch.close
|
71
71
|
end
|
@@ -79,10 +79,10 @@ describe Bunny::Queue, "#subscribe" do
|
|
79
79
|
delivery_tags = SortedSet.new
|
80
80
|
|
81
81
|
cch = connection.create_channel
|
82
|
-
q = cch.queue(queue_name, :
|
82
|
+
q = cch.queue(queue_name, auto_delete: true, durable: false)
|
83
83
|
|
84
84
|
7.times do
|
85
|
-
q.subscribe(:
|
85
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
86
86
|
delivery_tags << delivery_info.delivery_tag
|
87
87
|
end
|
88
88
|
end
|
@@ -91,13 +91,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
91
91
|
ch = connection.create_channel
|
92
92
|
x = ch.default_exchange
|
93
93
|
100.times do
|
94
|
-
x.publish("hello", :
|
94
|
+
x.publish("hello", routing_key: queue_name)
|
95
95
|
end
|
96
96
|
|
97
97
|
sleep 1.5
|
98
98
|
expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
|
99
99
|
|
100
|
-
expect(ch.queue(queue_name, :
|
100
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
101
101
|
|
102
102
|
ch.close
|
103
103
|
end
|
@@ -113,8 +113,8 @@ describe Bunny::Queue, "#subscribe" do
|
|
113
113
|
|
114
114
|
t = Thread.new do
|
115
115
|
ch = connection.create_channel
|
116
|
-
q = ch.queue(queue_name, :
|
117
|
-
q.subscribe(:
|
116
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
117
|
+
q.subscribe(exclusive: false, manual_ack: true) do |delivery_info, properties, payload|
|
118
118
|
delivered_keys << delivery_info.routing_key
|
119
119
|
delivered_data << payload
|
120
120
|
|
@@ -126,13 +126,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
126
126
|
|
127
127
|
ch = connection.create_channel
|
128
128
|
x = ch.default_exchange
|
129
|
-
x.publish("hello", :
|
129
|
+
x.publish("hello", routing_key: queue_name)
|
130
130
|
|
131
131
|
sleep 0.7
|
132
132
|
expect(delivered_keys).to include(queue_name)
|
133
133
|
expect(delivered_data).to include("hello")
|
134
134
|
|
135
|
-
expect(ch.queue(queue_name, :
|
135
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
136
136
|
|
137
137
|
ch.close
|
138
138
|
end
|
@@ -147,10 +147,10 @@ describe Bunny::Queue, "#subscribe" do
|
|
147
147
|
delivered_data = []
|
148
148
|
|
149
149
|
ch = connection.create_channel
|
150
|
-
q = ch.queue(queue_name, :
|
150
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
151
151
|
x = ch.default_exchange
|
152
152
|
100.times do
|
153
|
-
x.publish("hello", :
|
153
|
+
x.publish("hello", routing_key: queue_name)
|
154
154
|
end
|
155
155
|
|
156
156
|
sleep 0.7
|
@@ -158,8 +158,8 @@ describe Bunny::Queue, "#subscribe" do
|
|
158
158
|
|
159
159
|
t = Thread.new do
|
160
160
|
ch = connection.create_channel
|
161
|
-
q = ch.queue(queue_name, :
|
162
|
-
q.subscribe(:
|
161
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
162
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
163
163
|
delivered_keys << delivery_info.routing_key
|
164
164
|
delivered_data << payload
|
165
165
|
end
|
@@ -170,7 +170,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
170
170
|
expect(delivered_keys).to include(queue_name)
|
171
171
|
expect(delivered_data).to include("hello")
|
172
172
|
|
173
|
-
expect(ch.queue(queue_name, :
|
173
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
174
174
|
|
175
175
|
ch.close
|
176
176
|
end
|
@@ -189,17 +189,17 @@ describe Bunny::Queue, "#subscribe" do
|
|
189
189
|
ch = connection.create_channel
|
190
190
|
q = ch.queue(queue_name)
|
191
191
|
|
192
|
-
c1 = q.subscribe(:
|
192
|
+
c1 = q.subscribe(exclusive: false, manual_ack: false, block: false) do |delivery_info, properties, payload|
|
193
193
|
end
|
194
194
|
c1.cancel
|
195
195
|
|
196
|
-
c2 = q.subscribe(:
|
196
|
+
c2 = q.subscribe(exclusive: false, manual_ack: false, block: false) do |delivery_info, properties, payload|
|
197
197
|
delivered_keys << delivery_info.routing_key
|
198
198
|
delivered_data << payload
|
199
199
|
end
|
200
200
|
c2.cancel
|
201
201
|
|
202
|
-
q.subscribe(:
|
202
|
+
q.subscribe(exclusive: false, manual_ack: false, block: true) do |delivery_info, properties, payload|
|
203
203
|
delivered_keys << delivery_info.routing_key
|
204
204
|
delivered_data << payload
|
205
205
|
end
|
@@ -209,7 +209,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
209
209
|
|
210
210
|
ch = connection.create_channel
|
211
211
|
x = ch.default_exchange
|
212
|
-
x.publish("hello", :
|
212
|
+
x.publish("hello", routing_key: queue_name)
|
213
213
|
|
214
214
|
sleep 0.7
|
215
215
|
expect(delivered_keys).to include(queue_name)
|
@@ -231,13 +231,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
231
231
|
caught = nil
|
232
232
|
t = Thread.new do
|
233
233
|
ch = connection.create_channel
|
234
|
-
q = ch.queue(queue_name, :
|
234
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
235
235
|
|
236
236
|
ch.on_uncaught_exception do |e, consumer|
|
237
237
|
caught = e
|
238
238
|
end
|
239
239
|
|
240
|
-
q.subscribe(:
|
240
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
241
241
|
raise RuntimeError.new(queue_name)
|
242
242
|
end
|
243
243
|
end
|
@@ -246,7 +246,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
246
246
|
|
247
247
|
ch = connection.create_channel
|
248
248
|
x = ch.default_exchange
|
249
|
-
x.publish("hello", :
|
249
|
+
x.publish("hello", routing_key: queue_name)
|
250
250
|
sleep 0.5
|
251
251
|
|
252
252
|
expect(caught.message).to eq queue_name
|
@@ -265,9 +265,9 @@ describe Bunny::Queue, "#subscribe" do
|
|
265
265
|
allow(connection.logger).to receive(:error) { |x| caughts << x }
|
266
266
|
|
267
267
|
ch = connection.create_channel
|
268
|
-
q = ch.queue(queue_name, :
|
268
|
+
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
269
269
|
|
270
|
-
q.subscribe(:
|
270
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
271
271
|
raise RuntimeError.new(queue_name)
|
272
272
|
end
|
273
273
|
end
|
@@ -276,7 +276,7 @@ describe Bunny::Queue, "#subscribe" do
|
|
276
276
|
|
277
277
|
ch = connection.create_channel
|
278
278
|
x = ch.default_exchange
|
279
|
-
5.times { x.publish("hello", :
|
279
|
+
5.times { x.publish("hello", routing_key: queue_name) }
|
280
280
|
sleep 1.5
|
281
281
|
|
282
282
|
expect(caughts.size).to eq(5)
|
@@ -293,8 +293,8 @@ describe Bunny::Queue, "#subscribe" do
|
|
293
293
|
delivery_tags = SortedSet.new
|
294
294
|
|
295
295
|
cch = connection.create_channel
|
296
|
-
q = cch.queue(queue_name, :
|
297
|
-
q.subscribe(:
|
296
|
+
q = cch.queue(queue_name, auto_delete: true, durable: false)
|
297
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
298
298
|
delivery_tags << delivery_info.delivery_tag
|
299
299
|
end
|
300
300
|
sleep 0.5
|
@@ -302,13 +302,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
302
302
|
ch = connection.create_channel
|
303
303
|
x = ch.default_exchange
|
304
304
|
100.times do
|
305
|
-
x.publish("hello", :
|
305
|
+
x.publish("hello", routing_key: queue_name)
|
306
306
|
end
|
307
307
|
|
308
308
|
sleep 1.0
|
309
309
|
expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
|
310
310
|
|
311
|
-
expect(ch.queue(queue_name, :
|
311
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
312
312
|
|
313
313
|
ch.close
|
314
314
|
end
|
@@ -322,10 +322,10 @@ describe Bunny::Queue, "#subscribe" do
|
|
322
322
|
delivery_tags = SortedSet.new
|
323
323
|
|
324
324
|
cch = connection.create_channel
|
325
|
-
q = cch.queue(queue_name, :
|
325
|
+
q = cch.queue(queue_name, auto_delete: true, durable: false)
|
326
326
|
|
327
327
|
7.times do
|
328
|
-
q.subscribe(:
|
328
|
+
q.subscribe(exclusive: false, manual_ack: false) do |delivery_info, properties, payload|
|
329
329
|
delivery_tags << delivery_info.delivery_tag
|
330
330
|
end
|
331
331
|
end
|
@@ -334,13 +334,13 @@ describe Bunny::Queue, "#subscribe" do
|
|
334
334
|
ch = connection.create_channel
|
335
335
|
x = ch.default_exchange
|
336
336
|
100.times do
|
337
|
-
x.publish("hello", :
|
337
|
+
x.publish("hello", routing_key: queue_name)
|
338
338
|
end
|
339
339
|
|
340
340
|
sleep 1.5
|
341
341
|
expect(delivery_tags).to eq SortedSet.new(Range.new(1, 100).to_a)
|
342
342
|
|
343
|
-
expect(ch.queue(queue_name, :
|
343
|
+
expect(ch.queue(queue_name, auto_delete: true, durable: false).message_count).to eq 0
|
344
344
|
|
345
345
|
ch.close
|
346
346
|
end
|
@@ -3,7 +3,7 @@ require "set"
|
|
3
3
|
|
4
4
|
describe Bunny::Queue, "#subscribe_with" do
|
5
5
|
let(:connection) do
|
6
|
-
c = Bunny.new(:
|
6
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
7
7
|
c.start
|
8
8
|
c
|
9
9
|
end
|
@@ -32,19 +32,19 @@ describe Bunny::Queue, "#subscribe_with" do
|
|
32
32
|
it "requeues messages on channel closure" do
|
33
33
|
ch1 = connection.create_channel
|
34
34
|
ch2 = connection.create_channel
|
35
|
-
q1 = ch1.queue("bunny.tests.consumer_object1", :
|
36
|
-
q2 = ch2.queue("bunny.tests.consumer_object1", :
|
35
|
+
q1 = ch1.queue("bunny.tests.consumer_object1", exclusive: true)
|
36
|
+
q2 = ch2.queue("bunny.tests.consumer_object1", exclusive: true)
|
37
37
|
ec = ExampleConsumer.new(ch1, q1, "", false)
|
38
38
|
x = ch2.default_exchange
|
39
39
|
|
40
40
|
t = Thread.new do
|
41
41
|
50.times do
|
42
|
-
x.publish("hello", :
|
42
|
+
x.publish("hello", routing_key: q2.name)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
t.abort_on_exception = true
|
46
46
|
|
47
|
-
q1.subscribe_with(ec, :
|
47
|
+
q1.subscribe_with(ec, manual_ack: true)
|
48
48
|
sleep 2
|
49
49
|
ch1.close
|
50
50
|
|
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Queue, "#pop" do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
6
|
-
:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
|
6
|
+
automatically_recover: false)
|
7
7
|
c.start
|
8
8
|
c
|
9
9
|
end
|
@@ -16,11 +16,11 @@ describe Bunny::Queue, "#pop" do
|
|
16
16
|
it "fetches a messages which is automatically acknowledged" do
|
17
17
|
ch = connection.create_channel
|
18
18
|
|
19
|
-
q = ch.queue("", :
|
19
|
+
q = ch.queue("", exclusive: true)
|
20
20
|
x = ch.default_exchange
|
21
21
|
|
22
22
|
msg = "xyzzy"
|
23
|
-
x.publish(msg, :
|
23
|
+
x.publish(msg, routing_key: q.name)
|
24
24
|
|
25
25
|
sleep(0.5)
|
26
26
|
get_ok, properties, content = q.pop
|
@@ -41,7 +41,7 @@ describe Bunny::Queue, "#pop" do
|
|
41
41
|
it "returns an empty response" do
|
42
42
|
ch = connection.create_channel
|
43
43
|
|
44
|
-
q = ch.queue("", :
|
44
|
+
q = ch.queue("", exclusive: true)
|
45
45
|
q.purge
|
46
46
|
|
47
47
|
get_empty, properties, content = q.pop
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny::Channel, "#nack" do
|
4
4
|
let(:connection) do
|
5
|
-
c = Bunny.new(:
|
5
|
+
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
6
6
|
c.start
|
7
7
|
c
|
8
8
|
end
|
@@ -17,20 +17,20 @@ describe Bunny::Channel, "#nack" do
|
|
17
17
|
|
18
18
|
context "with requeue = false" do
|
19
19
|
it "rejects a message" do
|
20
|
-
q = subject.queue("bunny.basic.nack.with-requeue-false", :
|
20
|
+
q = subject.queue("bunny.basic.nack.with-requeue-false", exclusive: true)
|
21
21
|
x = subject.default_exchange
|
22
22
|
|
23
|
-
x.publish("bunneth", :
|
23
|
+
x.publish("bunneth", routing_key: q.name)
|
24
24
|
sleep(0.5)
|
25
25
|
expect(q.message_count).to eq 1
|
26
|
-
delivery_info, _, content = q.pop(:
|
26
|
+
delivery_info, _, content = q.pop(manual_ack: true)
|
27
27
|
|
28
28
|
subject.nack(delivery_info.delivery_tag, false, false)
|
29
29
|
sleep(0.5)
|
30
30
|
subject.close
|
31
31
|
|
32
32
|
ch = connection.create_channel
|
33
|
-
q = ch.queue("bunny.basic.nack.with-requeue-false", :
|
33
|
+
q = ch.queue("bunny.basic.nack.with-requeue-false", exclusive: true)
|
34
34
|
expect(q.message_count).to eq 0
|
35
35
|
ch.close
|
36
36
|
end
|
@@ -38,17 +38,17 @@ describe Bunny::Channel, "#nack" do
|
|
38
38
|
|
39
39
|
context "with multiple = true" do
|
40
40
|
it "rejects multiple messages" do
|
41
|
-
q = subject.queue("bunny.basic.nack.with-requeue-true-multi-true", :
|
41
|
+
q = subject.queue("bunny.basic.nack.with-requeue-true-multi-true", exclusive: true)
|
42
42
|
x = subject.default_exchange
|
43
43
|
|
44
44
|
3.times do
|
45
|
-
x.publish("bunneth", :
|
45
|
+
x.publish("bunneth", routing_key: q.name)
|
46
46
|
end
|
47
47
|
sleep(0.5)
|
48
48
|
expect(q.message_count).to eq 3
|
49
|
-
_, _, _ = q.pop(:
|
50
|
-
_, _, _ = q.pop(:
|
51
|
-
delivery_info, _, content = q.pop(:
|
49
|
+
_, _, _ = q.pop(manual_ack: true)
|
50
|
+
_, _, _ = q.pop(manual_ack: true)
|
51
|
+
delivery_info, _, content = q.pop(manual_ack: true)
|
52
52
|
|
53
53
|
subject.nack(delivery_info.delivery_tag, true, true)
|
54
54
|
sleep(0.5)
|
@@ -61,13 +61,13 @@ q = subject.queue("bunny.basic.nack.with-requeue-true-multi-true", :exclusive =>
|
|
61
61
|
|
62
62
|
context "with an invalid (random) delivery tag" do
|
63
63
|
it "causes a channel-level error" do
|
64
|
-
q = subject.queue("bunny.basic.nack.unknown-delivery-tag", :
|
64
|
+
q = subject.queue("bunny.basic.nack.unknown-delivery-tag", exclusive: true)
|
65
65
|
x = subject.default_exchange
|
66
66
|
|
67
|
-
x.publish("bunneth", :
|
67
|
+
x.publish("bunneth", routing_key: q.name)
|
68
68
|
sleep(0.25)
|
69
69
|
expect(q.message_count).to eq 1
|
70
|
-
_, _, content = q.pop(:
|
70
|
+
_, _, content = q.pop(manual_ack: true)
|
71
71
|
|
72
72
|
subject.on_error do |ch, channel_close|
|
73
73
|
@channel_close = channel_close
|