bbk-amqp 1.0.0.105683 → 1.0.0.105723
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 +20 -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: 2f1da8aba8b479f41ed976777c38ce799d5564a4f851351f3ee9d1e068b38e33
|
4
|
+
data.tar.gz: 97b64ced709b1ff88b9a02bd444de9826944a0af906c695625a4d3d0978062f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab0d20cb16a171f6b2e4cafec6d0fd5038994e28d1891753a89efceffeedb71bcf58370385fec709fab694f059111a3e1f4f829eb6eabbfe98d4ee5d17ed414f
|
7
|
+
data.tar.gz: 1234c97fb4ee02cf9cd3b85d5e5ff67ab6ce5ce12f73323b1bf961b4c9dea84c7240d0951dc05a6832669de4868953006e4d599595825262dc05612ca487978a
|
data/Gemfile.lock
CHANGED
data/lib/bbk/amqp/utils.rb
CHANGED
@@ -14,17 +14,28 @@ 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
|
19
|
+
# Если сообщений несколько то порядок может поменяться и это нужно иметь в виду.
|
20
|
+
# Решить можно создав, отдельный канал с qos 1.
|
17
21
|
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
|
22
|
+
mx.synchronize do
|
23
|
+
if consumed
|
24
|
+
queue.channel.nack(delivery_info.delivery_tag, false, true)
|
25
|
+
break
|
25
26
|
end
|
26
|
-
|
27
|
-
|
27
|
+
consumed = true
|
28
|
+
message = [
|
29
|
+
delivery_info,
|
30
|
+
metadata.to_hash.with_indifferent_access,
|
31
|
+
begin
|
32
|
+
Oj.load(payload).with_indifferent_access
|
33
|
+
rescue StandardError
|
34
|
+
payload
|
35
|
+
end
|
36
|
+
]
|
37
|
+
unblocker << message
|
38
|
+
end
|
28
39
|
end
|
29
40
|
Thread.new do
|
30
41
|
sleep timeout
|