bunny 2.19.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -32
- data/lib/bunny/channel.rb +86 -10
- data/lib/bunny/consumer.rb +2 -2
- data/lib/bunny/delivery_info.rb +1 -1
- data/lib/bunny/queue.rb +33 -2
- data/lib/bunny/session.rb +1 -1
- data/lib/bunny/transport.rb +30 -1
- data/lib/bunny/version.rb +1 -1
- data/lib/bunny.rb +45 -4
- metadata +4 -144
- data/spec/config/enabled_plugins +0 -1
- data/spec/config/rabbitmq.conf +0 -13
- data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
- data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -357
- 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 -80
- data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
- data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
- data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
- data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
- data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
- data/spec/higher_level_api/integration/channel_close_spec.rb +0 -66
- data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -483
- data/spec/higher_level_api/integration/connection_spec.rb +0 -589
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
- 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 -49
- 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 -191
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
- data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
- data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -285
- 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 -255
- data/spec/higher_level_api/integration/toxiproxy_spec.rb +0 -76
- 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 -43
- data/spec/issues/issue202_spec.rb +0 -15
- data/spec/issues/issue224_spec.rb +0 -40
- data/spec/issues/issue465_spec.rb +0 -32
- data/spec/issues/issue549_spec.rb +0 -30
- data/spec/issues/issue609_spec.rb +0 -84
- data/spec/issues/issue78_spec.rb +0 -72
- data/spec/issues/issue83_spec.rb +0 -30
- data/spec/issues/issue97_attachment.json +0 -1
- data/spec/issues/issue97_spec.rb +0 -175
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
- data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
- data/spec/spec_helper.rb +0 -47
- data/spec/stress/channel_close_stress_spec.rb +0 -64
- data/spec/stress/channel_open_stress_spec.rb +0 -84
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
- data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
- data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
- data/spec/stress/connection_open_close_spec.rb +0 -52
- data/spec/stress/merry_go_round_spec.rb +0 -105
- data/spec/toxiproxy_helper.rb +0 -28
- 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/exchange_recovery_spec.rb +0 -39
- data/spec/unit/version_delivery_tag_spec.rb +0 -28
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Duncan
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2022-12-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: amq-protocol
|
@@ -101,76 +101,6 @@ files:
|
|
101
101
|
- lib/bunny/transport.rb
|
102
102
|
- lib/bunny/version.rb
|
103
103
|
- lib/bunny/versioned_delivery_tag.rb
|
104
|
-
- spec/config/enabled_plugins
|
105
|
-
- spec/config/rabbitmq.conf
|
106
|
-
- spec/higher_level_api/integration/basic_ack_spec.rb
|
107
|
-
- spec/higher_level_api/integration/basic_cancel_spec.rb
|
108
|
-
- spec/higher_level_api/integration/basic_consume_spec.rb
|
109
|
-
- spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
|
110
|
-
- spec/higher_level_api/integration/basic_get_spec.rb
|
111
|
-
- spec/higher_level_api/integration/basic_nack_spec.rb
|
112
|
-
- spec/higher_level_api/integration/basic_publish_spec.rb
|
113
|
-
- spec/higher_level_api/integration/basic_qos_spec.rb
|
114
|
-
- spec/higher_level_api/integration/basic_reject_spec.rb
|
115
|
-
- spec/higher_level_api/integration/basic_return_spec.rb
|
116
|
-
- spec/higher_level_api/integration/channel_close_spec.rb
|
117
|
-
- spec/higher_level_api/integration/channel_open_spec.rb
|
118
|
-
- spec/higher_level_api/integration/connection_recovery_spec.rb
|
119
|
-
- spec/higher_level_api/integration/connection_spec.rb
|
120
|
-
- spec/higher_level_api/integration/connection_stop_spec.rb
|
121
|
-
- spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb
|
122
|
-
- spec/higher_level_api/integration/dead_lettering_spec.rb
|
123
|
-
- spec/higher_level_api/integration/exchange_bind_spec.rb
|
124
|
-
- spec/higher_level_api/integration/exchange_declare_spec.rb
|
125
|
-
- spec/higher_level_api/integration/exchange_delete_spec.rb
|
126
|
-
- spec/higher_level_api/integration/exchange_unbind_spec.rb
|
127
|
-
- spec/higher_level_api/integration/exclusive_queue_spec.rb
|
128
|
-
- spec/higher_level_api/integration/heartbeat_spec.rb
|
129
|
-
- spec/higher_level_api/integration/message_properties_access_spec.rb
|
130
|
-
- spec/higher_level_api/integration/predeclared_exchanges_spec.rb
|
131
|
-
- spec/higher_level_api/integration/publisher_confirms_spec.rb
|
132
|
-
- spec/higher_level_api/integration/publishing_edge_cases_spec.rb
|
133
|
-
- spec/higher_level_api/integration/queue_bind_spec.rb
|
134
|
-
- spec/higher_level_api/integration/queue_declare_spec.rb
|
135
|
-
- spec/higher_level_api/integration/queue_delete_spec.rb
|
136
|
-
- spec/higher_level_api/integration/queue_purge_spec.rb
|
137
|
-
- spec/higher_level_api/integration/queue_unbind_spec.rb
|
138
|
-
- spec/higher_level_api/integration/read_only_consumer_spec.rb
|
139
|
-
- spec/higher_level_api/integration/sender_selected_distribution_spec.rb
|
140
|
-
- spec/higher_level_api/integration/tls_connection_spec.rb
|
141
|
-
- spec/higher_level_api/integration/toxiproxy_spec.rb
|
142
|
-
- spec/higher_level_api/integration/tx_commit_spec.rb
|
143
|
-
- spec/higher_level_api/integration/tx_rollback_spec.rb
|
144
|
-
- spec/higher_level_api/integration/with_channel_spec.rb
|
145
|
-
- spec/issues/issue100_spec.rb
|
146
|
-
- spec/issues/issue141_spec.rb
|
147
|
-
- spec/issues/issue202_spec.rb
|
148
|
-
- spec/issues/issue224_spec.rb
|
149
|
-
- spec/issues/issue465_spec.rb
|
150
|
-
- spec/issues/issue549_spec.rb
|
151
|
-
- spec/issues/issue609_spec.rb
|
152
|
-
- spec/issues/issue78_spec.rb
|
153
|
-
- spec/issues/issue83_spec.rb
|
154
|
-
- spec/issues/issue97_attachment.json
|
155
|
-
- spec/issues/issue97_spec.rb
|
156
|
-
- spec/lower_level_api/integration/basic_cancel_spec.rb
|
157
|
-
- spec/lower_level_api/integration/basic_consume_spec.rb
|
158
|
-
- spec/spec_helper.rb
|
159
|
-
- spec/stress/channel_close_stress_spec.rb
|
160
|
-
- spec/stress/channel_open_stress_spec.rb
|
161
|
-
- spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb
|
162
|
-
- spec/stress/concurrent_consumers_stress_spec.rb
|
163
|
-
- spec/stress/concurrent_publishers_stress_spec.rb
|
164
|
-
- spec/stress/connection_open_close_spec.rb
|
165
|
-
- spec/stress/merry_go_round_spec.rb
|
166
|
-
- spec/toxiproxy_helper.rb
|
167
|
-
- spec/unit/bunny_spec.rb
|
168
|
-
- spec/unit/concurrent/atomic_fixnum_spec.rb
|
169
|
-
- spec/unit/concurrent/condition_spec.rb
|
170
|
-
- spec/unit/concurrent/linked_continuation_queue_spec.rb
|
171
|
-
- spec/unit/concurrent/synchronized_sorted_set_spec.rb
|
172
|
-
- spec/unit/exchange_recovery_spec.rb
|
173
|
-
- spec/unit/version_delivery_tag_spec.rb
|
174
104
|
homepage: http://rubybunny.info
|
175
105
|
licenses:
|
176
106
|
- MIT
|
@@ -183,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
113
|
requirements:
|
184
114
|
- - ">="
|
185
115
|
- !ruby/object:Gem::Version
|
186
|
-
version: '2.
|
116
|
+
version: '2.5'
|
187
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
118
|
requirements:
|
189
119
|
- - ">="
|
@@ -194,74 +124,4 @@ rubygems_version: 3.1.4
|
|
194
124
|
signing_key:
|
195
125
|
specification_version: 4
|
196
126
|
summary: Popular easy to use Ruby client for RabbitMQ
|
197
|
-
test_files:
|
198
|
-
- spec/config/enabled_plugins
|
199
|
-
- spec/config/rabbitmq.conf
|
200
|
-
- spec/higher_level_api/integration/basic_ack_spec.rb
|
201
|
-
- spec/higher_level_api/integration/basic_cancel_spec.rb
|
202
|
-
- spec/higher_level_api/integration/basic_consume_spec.rb
|
203
|
-
- spec/higher_level_api/integration/basic_consume_with_objects_spec.rb
|
204
|
-
- spec/higher_level_api/integration/basic_get_spec.rb
|
205
|
-
- spec/higher_level_api/integration/basic_nack_spec.rb
|
206
|
-
- spec/higher_level_api/integration/basic_publish_spec.rb
|
207
|
-
- spec/higher_level_api/integration/basic_qos_spec.rb
|
208
|
-
- spec/higher_level_api/integration/basic_reject_spec.rb
|
209
|
-
- spec/higher_level_api/integration/basic_return_spec.rb
|
210
|
-
- spec/higher_level_api/integration/channel_close_spec.rb
|
211
|
-
- spec/higher_level_api/integration/channel_open_spec.rb
|
212
|
-
- spec/higher_level_api/integration/connection_recovery_spec.rb
|
213
|
-
- spec/higher_level_api/integration/connection_spec.rb
|
214
|
-
- spec/higher_level_api/integration/connection_stop_spec.rb
|
215
|
-
- spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb
|
216
|
-
- spec/higher_level_api/integration/dead_lettering_spec.rb
|
217
|
-
- spec/higher_level_api/integration/exchange_bind_spec.rb
|
218
|
-
- spec/higher_level_api/integration/exchange_declare_spec.rb
|
219
|
-
- spec/higher_level_api/integration/exchange_delete_spec.rb
|
220
|
-
- spec/higher_level_api/integration/exchange_unbind_spec.rb
|
221
|
-
- spec/higher_level_api/integration/exclusive_queue_spec.rb
|
222
|
-
- spec/higher_level_api/integration/heartbeat_spec.rb
|
223
|
-
- spec/higher_level_api/integration/message_properties_access_spec.rb
|
224
|
-
- spec/higher_level_api/integration/predeclared_exchanges_spec.rb
|
225
|
-
- spec/higher_level_api/integration/publisher_confirms_spec.rb
|
226
|
-
- spec/higher_level_api/integration/publishing_edge_cases_spec.rb
|
227
|
-
- spec/higher_level_api/integration/queue_bind_spec.rb
|
228
|
-
- spec/higher_level_api/integration/queue_declare_spec.rb
|
229
|
-
- spec/higher_level_api/integration/queue_delete_spec.rb
|
230
|
-
- spec/higher_level_api/integration/queue_purge_spec.rb
|
231
|
-
- spec/higher_level_api/integration/queue_unbind_spec.rb
|
232
|
-
- spec/higher_level_api/integration/read_only_consumer_spec.rb
|
233
|
-
- spec/higher_level_api/integration/sender_selected_distribution_spec.rb
|
234
|
-
- spec/higher_level_api/integration/tls_connection_spec.rb
|
235
|
-
- spec/higher_level_api/integration/toxiproxy_spec.rb
|
236
|
-
- spec/higher_level_api/integration/tx_commit_spec.rb
|
237
|
-
- spec/higher_level_api/integration/tx_rollback_spec.rb
|
238
|
-
- spec/higher_level_api/integration/with_channel_spec.rb
|
239
|
-
- spec/issues/issue100_spec.rb
|
240
|
-
- spec/issues/issue141_spec.rb
|
241
|
-
- spec/issues/issue202_spec.rb
|
242
|
-
- spec/issues/issue224_spec.rb
|
243
|
-
- spec/issues/issue465_spec.rb
|
244
|
-
- spec/issues/issue549_spec.rb
|
245
|
-
- spec/issues/issue609_spec.rb
|
246
|
-
- spec/issues/issue78_spec.rb
|
247
|
-
- spec/issues/issue83_spec.rb
|
248
|
-
- spec/issues/issue97_attachment.json
|
249
|
-
- spec/issues/issue97_spec.rb
|
250
|
-
- spec/lower_level_api/integration/basic_cancel_spec.rb
|
251
|
-
- spec/lower_level_api/integration/basic_consume_spec.rb
|
252
|
-
- spec/spec_helper.rb
|
253
|
-
- spec/stress/channel_close_stress_spec.rb
|
254
|
-
- spec/stress/channel_open_stress_spec.rb
|
255
|
-
- spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb
|
256
|
-
- spec/stress/concurrent_consumers_stress_spec.rb
|
257
|
-
- spec/stress/concurrent_publishers_stress_spec.rb
|
258
|
-
- spec/stress/connection_open_close_spec.rb
|
259
|
-
- spec/stress/merry_go_round_spec.rb
|
260
|
-
- spec/toxiproxy_helper.rb
|
261
|
-
- spec/unit/bunny_spec.rb
|
262
|
-
- spec/unit/concurrent/atomic_fixnum_spec.rb
|
263
|
-
- spec/unit/concurrent/condition_spec.rb
|
264
|
-
- spec/unit/concurrent/linked_continuation_queue_spec.rb
|
265
|
-
- spec/unit/concurrent/synchronized_sorted_set_spec.rb
|
266
|
-
- spec/unit/exchange_recovery_spec.rb
|
267
|
-
- spec/unit/version_delivery_tag_spec.rb
|
127
|
+
test_files: []
|
data/spec/config/enabled_plugins
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
[rabbitmq_management, rabbitmq_consistent_hash_exchange].
|
data/spec/config/rabbitmq.conf
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
listeners.tcp.1 = 0.0.0.0:5672
|
2
|
-
|
3
|
-
listeners.ssl.default = 5671
|
4
|
-
|
5
|
-
# mounted by docker-compose
|
6
|
-
ssl_options.cacertfile = /spec/tls/ca_certificate.pem
|
7
|
-
ssl_options.certfile = /spec/tls/server_certificate.pem
|
8
|
-
ssl_options.keyfile = /spec/tls/server_key.pem
|
9
|
-
|
10
|
-
ssl_options.verify = verify_none
|
11
|
-
ssl_options.fail_if_no_peer_cert = false
|
12
|
-
|
13
|
-
loopback_users = none
|
@@ -1,230 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#ack" 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 a valid (known) delivery tag" do
|
15
|
-
it "acknowledges a message" do
|
16
|
-
ch = connection.create_channel
|
17
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
18
|
-
x = ch.default_exchange
|
19
|
-
|
20
|
-
x.publish("bunneth", routing_key: q.name)
|
21
|
-
sleep 0.5
|
22
|
-
expect(q.message_count).to eq 1
|
23
|
-
delivery_details, properties, content = q.pop(manual_ack: true)
|
24
|
-
|
25
|
-
ch.ack(delivery_details.delivery_tag, true)
|
26
|
-
ch.close
|
27
|
-
|
28
|
-
ch = connection.create_channel
|
29
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
30
|
-
expect(q.message_count).to eq 0
|
31
|
-
ch.close
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with a valid (known) delivery tag (multiple = true)" do
|
36
|
-
it "acknowledges a message" do
|
37
|
-
ch = connection.create_channel
|
38
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
39
|
-
x = ch.default_exchange
|
40
|
-
|
41
|
-
x.publish("bunneth", routing_key: q.name)
|
42
|
-
x.publish("bunneth", routing_key: q.name)
|
43
|
-
sleep 0.5
|
44
|
-
expect(q.message_count).to eq 2
|
45
|
-
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
46
|
-
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
47
|
-
|
48
|
-
ch.ack(delivery_details_2.delivery_tag, true)
|
49
|
-
ch.close
|
50
|
-
|
51
|
-
ch = connection.create_channel
|
52
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
53
|
-
expect(q.message_count).to eq 0
|
54
|
-
ch.close
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "with a valid (known) delivery tag (multiple = false)" do
|
59
|
-
it "acknowledges a message" do
|
60
|
-
ch = connection.create_channel
|
61
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
62
|
-
x = ch.default_exchange
|
63
|
-
|
64
|
-
x.publish("bunneth", routing_key: q.name)
|
65
|
-
x.publish("bunneth", routing_key: q.name)
|
66
|
-
sleep 0.5
|
67
|
-
expect(q.message_count).to eq 2
|
68
|
-
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
69
|
-
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
70
|
-
|
71
|
-
ch.ack(delivery_details_2.delivery_tag, false)
|
72
|
-
ch.close
|
73
|
-
|
74
|
-
ch = connection.create_channel
|
75
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
76
|
-
expect(q.message_count).to eq 1
|
77
|
-
ch.close
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with a valid (known) delivery tag and automatic ack mode" do
|
82
|
-
it "results in a channel exception" do
|
83
|
-
ch = connection.create_channel
|
84
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
85
|
-
x = ch.default_exchange
|
86
|
-
|
87
|
-
q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
|
88
|
-
ch.ack(delivery_info.delivery_tag, false)
|
89
|
-
end
|
90
|
-
|
91
|
-
x.publish("bunneth", routing_key: q.name)
|
92
|
-
sleep 0.5
|
93
|
-
expect do
|
94
|
-
q.message_count
|
95
|
-
end.to raise_error(Bunny::ChannelAlreadyClosed)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "with an invalid (random) delivery tag" do
|
100
|
-
it "causes a channel-level error" do
|
101
|
-
ch = connection.create_channel
|
102
|
-
q = ch.queue("bunny.basic.ack.unknown-delivery-tag", exclusive: true)
|
103
|
-
x = ch.default_exchange
|
104
|
-
|
105
|
-
x.publish("bunneth", routing_key: q.name)
|
106
|
-
sleep 0.5
|
107
|
-
expect(q.message_count).to eq 1
|
108
|
-
_, _, content = q.pop(manual_ack: true)
|
109
|
-
|
110
|
-
ch.on_error do |ch, channel_close|
|
111
|
-
@channel_close = channel_close
|
112
|
-
end
|
113
|
-
ch.ack(82, true)
|
114
|
-
sleep 0.25
|
115
|
-
|
116
|
-
expect(@channel_close.reply_code).to eq AMQ::Protocol::PreconditionFailed::VALUE
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context "with a valid (known) delivery tag" do
|
121
|
-
it "gets a depricated message warning for using :ack" do
|
122
|
-
ch = connection.create_channel
|
123
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
124
|
-
x = ch.default_exchange
|
125
|
-
|
126
|
-
x.publish("bunneth", routing_key: q.name)
|
127
|
-
sleep 0.5
|
128
|
-
expect(q.message_count).to eq 1
|
129
|
-
|
130
|
-
orig_stderr = $stderr
|
131
|
-
$stderr = StringIO.new
|
132
|
-
|
133
|
-
delivery_details, properties, content = q.pop(ack: true)
|
134
|
-
|
135
|
-
$stderr.rewind
|
136
|
-
expect($stderr.string.chomp).to eq("[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead.\n[DEPRECATION] `:ack` is deprecated. Please use `:manual_ack` instead.")
|
137
|
-
|
138
|
-
$stderr = orig_stderr
|
139
|
-
|
140
|
-
ch.ack(delivery_details.delivery_tag, true)
|
141
|
-
ch.close
|
142
|
-
|
143
|
-
ch = connection.create_channel
|
144
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
145
|
-
expect(q.message_count).to eq 0
|
146
|
-
ch.close
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe Bunny::Channel, "#basic_ack" do
|
152
|
-
let(:connection) do
|
153
|
-
c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
|
154
|
-
c.start
|
155
|
-
c
|
156
|
-
end
|
157
|
-
|
158
|
-
after :each do
|
159
|
-
connection.close if connection.open?
|
160
|
-
end
|
161
|
-
|
162
|
-
context "with a valid (known) delivery tag (multiple = true)" do
|
163
|
-
it "acknowledges a message" do
|
164
|
-
ch = connection.create_channel
|
165
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
166
|
-
x = ch.default_exchange
|
167
|
-
|
168
|
-
x.publish("bunneth", routing_key: q.name)
|
169
|
-
x.publish("bunneth", routing_key: q.name)
|
170
|
-
sleep 0.5
|
171
|
-
expect(q.message_count).to eq 2
|
172
|
-
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
173
|
-
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
174
|
-
|
175
|
-
ch.basic_ack(delivery_details_2.delivery_tag.to_i, true)
|
176
|
-
ch.close
|
177
|
-
|
178
|
-
ch = connection.create_channel
|
179
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
180
|
-
expect(q.message_count).to eq 0
|
181
|
-
ch.close
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context "with a valid (known) delivery tag (multiple = false)" do
|
186
|
-
it "acknowledges a message" do
|
187
|
-
ch = connection.create_channel
|
188
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
189
|
-
x = ch.default_exchange
|
190
|
-
|
191
|
-
x.publish("bunneth", routing_key: q.name)
|
192
|
-
x.publish("bunneth", routing_key: q.name)
|
193
|
-
sleep 0.5
|
194
|
-
expect(q.message_count).to eq 2
|
195
|
-
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
196
|
-
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
197
|
-
|
198
|
-
ch.basic_ack(delivery_details_2.delivery_tag.to_i, false)
|
199
|
-
ch.close
|
200
|
-
|
201
|
-
ch = connection.create_channel
|
202
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
203
|
-
expect(q.message_count).to eq 1
|
204
|
-
ch.close
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
context "with a valid (known) delivery tag (multiple = default)" do
|
209
|
-
it "acknowledges a message" do
|
210
|
-
ch = connection.create_channel
|
211
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
212
|
-
x = ch.default_exchange
|
213
|
-
|
214
|
-
x.publish("bunneth", routing_key: q.name)
|
215
|
-
x.publish("bunneth", routing_key: q.name)
|
216
|
-
sleep 0.5
|
217
|
-
expect(q.message_count).to eq 2
|
218
|
-
delivery_details_1, _properties, _content = q.pop(manual_ack: true)
|
219
|
-
delivery_details_2, _properties, _content = q.pop(manual_ack: true)
|
220
|
-
|
221
|
-
ch.basic_ack(delivery_details_2.delivery_tag.to_i)
|
222
|
-
ch.close
|
223
|
-
|
224
|
-
ch = connection.create_channel
|
225
|
-
q = ch.queue("bunny.basic.ack.manual-acks", exclusive: true)
|
226
|
-
expect(q.message_count).to eq 1
|
227
|
-
ch.close
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Consumer, "#cancel" 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 a non-blocking consumer" do
|
15
|
-
let(:queue_name) { "bunny.queues.#{rand}" }
|
16
|
-
|
17
|
-
it "cancels the consumer" do
|
18
|
-
delivered_data = []
|
19
|
-
|
20
|
-
t = Thread.new do
|
21
|
-
ch = connection.create_channel
|
22
|
-
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
23
|
-
consumer = q.subscribe do |_, _, payload|
|
24
|
-
delivered_data << payload
|
25
|
-
end
|
26
|
-
|
27
|
-
expect(consumer.consumer_tag).not_to be_nil
|
28
|
-
cancel_ok = consumer.cancel
|
29
|
-
expect(cancel_ok.consumer_tag).to eq consumer.consumer_tag
|
30
|
-
|
31
|
-
ch.close
|
32
|
-
end
|
33
|
-
t.abort_on_exception = true
|
34
|
-
sleep 0.5
|
35
|
-
|
36
|
-
ch = connection.create_channel
|
37
|
-
ch.default_exchange.publish("", routing_key: queue_name)
|
38
|
-
|
39
|
-
sleep 0.7
|
40
|
-
expect(delivered_data).to be_empty
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
context "with a blocking consumer" do
|
46
|
-
let(:queue_name) { "bunny.queues.#{rand}" }
|
47
|
-
|
48
|
-
it "cancels the consumer" do
|
49
|
-
delivered_data = []
|
50
|
-
consumer = nil
|
51
|
-
|
52
|
-
t = Thread.new do
|
53
|
-
ch = connection.create_channel
|
54
|
-
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
55
|
-
|
56
|
-
consumer = Bunny::Consumer.new(ch, q)
|
57
|
-
consumer.on_delivery do |_, _, payload|
|
58
|
-
delivered_data << payload
|
59
|
-
end
|
60
|
-
|
61
|
-
q.subscribe_with(consumer)
|
62
|
-
end
|
63
|
-
t.abort_on_exception = true
|
64
|
-
sleep 1.0
|
65
|
-
|
66
|
-
consumer.cancel
|
67
|
-
sleep 1.0
|
68
|
-
|
69
|
-
ch = connection.create_channel
|
70
|
-
ch.default_exchange.publish("", routing_key: queue_name)
|
71
|
-
|
72
|
-
sleep 0.7
|
73
|
-
expect(delivered_data).to be_empty
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with a worker pool shutdown timeout configured" do
|
78
|
-
let(:queue_name) { "bunny.queues.#{rand}" }
|
79
|
-
|
80
|
-
it "processes the message if processing completes within the timeout" do
|
81
|
-
delivered_data = []
|
82
|
-
consumer = nil
|
83
|
-
|
84
|
-
t = Thread.new do
|
85
|
-
ch = connection.create_channel(nil, 1, false, 5)
|
86
|
-
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
87
|
-
|
88
|
-
consumer = Bunny::Consumer.new(ch, q)
|
89
|
-
consumer.on_delivery do |_, _, payload|
|
90
|
-
sleep 2
|
91
|
-
delivered_data << payload
|
92
|
-
end
|
93
|
-
|
94
|
-
q.subscribe_with(consumer)
|
95
|
-
end
|
96
|
-
t.abort_on_exception = true
|
97
|
-
sleep 1.0
|
98
|
-
|
99
|
-
ch = connection.create_channel
|
100
|
-
ch.confirm_select
|
101
|
-
ch.default_exchange.publish("", routing_key: queue_name)
|
102
|
-
ch.wait_for_confirms
|
103
|
-
sleep 0.5
|
104
|
-
|
105
|
-
consumer.cancel
|
106
|
-
sleep 1.0
|
107
|
-
|
108
|
-
expect(delivered_data).to_not be_empty
|
109
|
-
end
|
110
|
-
|
111
|
-
it "kills the consumer if processing takes longer than the timeout" do
|
112
|
-
delivered_data = []
|
113
|
-
consumer = nil
|
114
|
-
|
115
|
-
t = Thread.new do
|
116
|
-
ch = connection.create_channel(nil, 1, false, 1)
|
117
|
-
q = ch.queue(queue_name, auto_delete: true, durable: false)
|
118
|
-
|
119
|
-
consumer = Bunny::Consumer.new(ch, q)
|
120
|
-
consumer.on_delivery do |_, _, payload|
|
121
|
-
sleep 3
|
122
|
-
delivered_data << payload
|
123
|
-
end
|
124
|
-
|
125
|
-
q.subscribe_with(consumer)
|
126
|
-
end
|
127
|
-
t.abort_on_exception = true
|
128
|
-
sleep 1.0
|
129
|
-
|
130
|
-
ch = connection.create_channel
|
131
|
-
ch.confirm_select
|
132
|
-
ch.default_exchange.publish("", routing_key: queue_name)
|
133
|
-
ch.wait_for_confirms
|
134
|
-
sleep 0.5
|
135
|
-
|
136
|
-
consumer.cancel
|
137
|
-
sleep 1.0
|
138
|
-
|
139
|
-
expect(delivered_data).to be_empty
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|