bunny 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.md +15 -1
- data/lib/bunny/channel.rb +16 -1
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_consume_spec.rb +119 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549beacd9dcbe811dd5ad11c61efa51746eda01f
|
4
|
+
data.tar.gz: ed9a4c5d128c707122504fdfdae94556794d5633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c90fb4df6a1ae0edff196e9b4cea4f2c7fc424b184dc6bc3b4215af3f01149442c57fd3eea2d857b733c05ebb2eb0d7530bb704fb55a50d832422a16a616bd
|
7
|
+
data.tar.gz: 87b6dc534478f963b80a82b06a4ccfbfb21bbbc01ee07c580e525bda26e0c86969d6b64890bac8afcd1b456f632b8edd537f61eca2fdf6dbf644453f99e5cdba
|
data/ChangeLog.md
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
## Changes between Bunny 1.1.0
|
1
|
+
## Changes between Bunny 1.1.0 and 1.1.1
|
2
|
+
|
3
|
+
### Uncaught Consumer Exceptions
|
4
|
+
|
5
|
+
Uncaught consumer exceptions are now handled by uncaught exceptions
|
6
|
+
handler that can be defined per channel:
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
ch.on_uncaught_exception do |e, consumer|
|
10
|
+
# ...
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
|
15
|
+
## Changes between Bunny 1.1.0.rc1 and 1.1.0
|
2
16
|
|
3
17
|
### Synchronized Session#create_channel and Session#close_channel
|
4
18
|
|
data/lib/bunny/channel.rb
CHANGED
@@ -193,6 +193,9 @@ module Bunny
|
|
193
193
|
@next_publish_seq_no = 0
|
194
194
|
|
195
195
|
@recoveries_counter = Bunny::Concurrent::AtomicFixnum.new(0)
|
196
|
+
@uncaught_exception_handler = Proc.new do |e, consumer|
|
197
|
+
@logger.error "Uncaught exception from consumer #{consumer.to_s}: #{e.message}"
|
198
|
+
end
|
196
199
|
end
|
197
200
|
|
198
201
|
attr_reader :recoveries_counter
|
@@ -1406,6 +1409,13 @@ module Bunny
|
|
1406
1409
|
@on_error = block
|
1407
1410
|
end
|
1408
1411
|
|
1412
|
+
# Defines a handler for uncaught exceptions in consumers
|
1413
|
+
# (e.g. delivered message handlers).
|
1414
|
+
#
|
1415
|
+
# @api public
|
1416
|
+
def on_uncaught_exception(&block)
|
1417
|
+
@uncaught_exception_handler = block
|
1418
|
+
end
|
1409
1419
|
|
1410
1420
|
#
|
1411
1421
|
# Recovery
|
@@ -1569,6 +1579,7 @@ module Bunny
|
|
1569
1579
|
consumer.handle_cancellation(method)
|
1570
1580
|
rescue Exception => e
|
1571
1581
|
@logger.error "Got exception when notifying consumer #{method.consumer_tag} about cancellation!"
|
1582
|
+
@uncaught_exception_handler.call(e, consumer) if @uncaught_exception_handler
|
1572
1583
|
end
|
1573
1584
|
end
|
1574
1585
|
else
|
@@ -1627,7 +1638,11 @@ module Bunny
|
|
1627
1638
|
consumer = @consumers[basic_deliver.consumer_tag]
|
1628
1639
|
if consumer
|
1629
1640
|
@work_pool.submit do
|
1630
|
-
|
1641
|
+
begin
|
1642
|
+
consumer.call(DeliveryInfo.new(basic_deliver, consumer, self), MessageProperties.new(properties), content)
|
1643
|
+
rescue StandardError => e
|
1644
|
+
@uncaught_exception_handler.call(e, consumer) if @uncaught_exception_handler
|
1645
|
+
end
|
1631
1646
|
end
|
1632
1647
|
else
|
1633
1648
|
@logger.warn "No consumer for tag #{basic_deliver.consumer_tag} on channel #{@id}!"
|
data/lib/bunny/version.rb
CHANGED
@@ -222,4 +222,123 @@ describe Bunny::Queue, "#subscribe" do
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
+
|
226
|
+
context "with uncaught exceptions in delivery handler" do
|
227
|
+
context "and defined exception handler" do
|
228
|
+
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
229
|
+
|
230
|
+
it "uses exception handler" do
|
231
|
+
caught = nil
|
232
|
+
t = Thread.new do
|
233
|
+
ch = connection.create_channel
|
234
|
+
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
|
235
|
+
|
236
|
+
ch.on_uncaught_exception do |e, consumer|
|
237
|
+
caught = e
|
238
|
+
end
|
239
|
+
|
240
|
+
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
241
|
+
raise RuntimeError.new(queue_name)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
t.abort_on_exception = true
|
245
|
+
sleep 0.5
|
246
|
+
|
247
|
+
ch = connection.create_channel
|
248
|
+
x = ch.default_exchange
|
249
|
+
x.publish("hello", :routing_key => queue_name)
|
250
|
+
sleep 0.5
|
251
|
+
|
252
|
+
caught.message.should == queue_name
|
253
|
+
|
254
|
+
ch.close
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
context "and default exception handler" do
|
260
|
+
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
261
|
+
|
262
|
+
it "uses exception handler" do
|
263
|
+
t = Thread.new do
|
264
|
+
ch = connection.create_channel
|
265
|
+
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
|
266
|
+
|
267
|
+
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
268
|
+
raise RuntimeError.new(queue_name)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
t.abort_on_exception = true
|
272
|
+
sleep 0.5
|
273
|
+
|
274
|
+
ch = connection.create_channel
|
275
|
+
x = ch.default_exchange
|
276
|
+
5.times { x.publish("hello", :routing_key => queue_name) }
|
277
|
+
sleep 1.5
|
278
|
+
|
279
|
+
ch.close
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
|
284
|
+
context "with a single consumer" do
|
285
|
+
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
286
|
+
|
287
|
+
it "provides delivery tag access" do
|
288
|
+
delivery_tags = SortedSet.new
|
289
|
+
|
290
|
+
cch = connection.create_channel
|
291
|
+
q = cch.queue(queue_name, :auto_delete => true, :durable => false)
|
292
|
+
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
293
|
+
delivery_tags << delivery_info.delivery_tag
|
294
|
+
end
|
295
|
+
sleep 0.5
|
296
|
+
|
297
|
+
ch = connection.create_channel
|
298
|
+
x = ch.default_exchange
|
299
|
+
100.times do
|
300
|
+
x.publish("hello", :routing_key => queue_name)
|
301
|
+
end
|
302
|
+
|
303
|
+
sleep 1.0
|
304
|
+
delivery_tags.should == SortedSet.new(Range.new(1, 100).to_a)
|
305
|
+
|
306
|
+
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0
|
307
|
+
|
308
|
+
ch.close
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
|
313
|
+
context "with multiple consumers on the same channel" do
|
314
|
+
let(:queue_name) { "bunny.basic_consume#{rand}" }
|
315
|
+
|
316
|
+
it "provides delivery tag access" do
|
317
|
+
delivery_tags = SortedSet.new
|
318
|
+
|
319
|
+
cch = connection.create_channel
|
320
|
+
q = cch.queue(queue_name, :auto_delete => true, :durable => false)
|
321
|
+
|
322
|
+
7.times do
|
323
|
+
q.subscribe(:exclusive => false, :manual_ack => false) do |delivery_info, properties, payload|
|
324
|
+
delivery_tags << delivery_info.delivery_tag
|
325
|
+
end
|
326
|
+
end
|
327
|
+
sleep 1.0
|
328
|
+
|
329
|
+
ch = connection.create_channel
|
330
|
+
x = ch.default_exchange
|
331
|
+
100.times do
|
332
|
+
x.publish("hello", :routing_key => queue_name)
|
333
|
+
end
|
334
|
+
|
335
|
+
sleep 1.5
|
336
|
+
delivery_tags.should == SortedSet.new(Range.new(1, 100).to_a)
|
337
|
+
|
338
|
+
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0
|
339
|
+
|
340
|
+
ch.close
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
225
344
|
end # describe
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
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: 2014-01-
|
15
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: amq-protocol
|