bbk-amqp 1.0.0.105635 → 1.0.0.105722
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bbk/amqp/utils.rb +18 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c548372181f2dd8188ed0aee86a514a0cf9d2d533d534211cd00d3e2137f1945
|
4
|
+
data.tar.gz: 2afa60b894ff011b639ea8f1a9de931570feb4bbe2ddd6c2061474ac3d01f0a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06be7f99a98d9a80a0414c2bc96ec4990fd6c50177ff89c8e8462b20a00e445449532008c70873e23f9b26102655858d0f35b80c1e9fbb89c4729ab1281cda56
|
7
|
+
data.tar.gz: 1a9d618b0561e1fba5da9d23ad5c5000b2e66ef4e8a23657447968f74762539f249b98aecd307fd53fb2491d8adbeb1a10fdce2fca2d752ffe312cc76c7d1db0
|
data/Gemfile.lock
CHANGED
data/lib/bbk/amqp/utils.rb
CHANGED
@@ -14,17 +14,26 @@ module BBK
|
|
14
14
|
# @return [Array] array with delivery_info, metadata and payload
|
15
15
|
def self.pop(queue, timeout = 10)
|
16
16
|
unblocker = Queue.new
|
17
|
+
consumed = false
|
18
|
+
mx = Mutex.new
|
17
19
|
consumer = queue.subscribe(block: false, manual_ack: true) do |delivery_info, metadata, payload|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Oj.load(payload).with_indifferent_access
|
23
|
-
rescue StandardError
|
24
|
-
payload
|
20
|
+
mx.synchronize do
|
21
|
+
if consumed
|
22
|
+
queue.channel.nack(delivery_info.delivery_tag, false, true)
|
23
|
+
break
|
25
24
|
end
|
26
|
-
|
27
|
-
|
25
|
+
consumed = true
|
26
|
+
message = [
|
27
|
+
delivery_info,
|
28
|
+
metadata.to_hash.with_indifferent_access,
|
29
|
+
begin
|
30
|
+
Oj.load(payload).with_indifferent_access
|
31
|
+
rescue StandardError
|
32
|
+
payload
|
33
|
+
end
|
34
|
+
]
|
35
|
+
unblocker << message
|
36
|
+
end
|
28
37
|
end
|
29
38
|
Thread.new do
|
30
39
|
sleep timeout
|