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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/bbk/amqp/utils.rb +20 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b0cf40f223ad98321c2585561830b848c5f5f910c3735e58f25e89c10c27495
4
- data.tar.gz: f5557d4fcdc315583d2d3dece0162e1a5316a149b901cf9a6da7b23caa51a22d
3
+ metadata.gz: 2f1da8aba8b479f41ed976777c38ce799d5564a4f851351f3ee9d1e068b38e33
4
+ data.tar.gz: 97b64ced709b1ff88b9a02bd444de9826944a0af906c695625a4d3d0978062f2
5
5
  SHA512:
6
- metadata.gz: 85a5f458d11e8b29765478aa79ff70f9b6b5d1cf35905172ca7801fe8f697cc07ea1009131f369c16cb99e5a243ddf7c2ef4c48fe16ae9ce62912b5ee1a4c21a
7
- data.tar.gz: 3e576a2335e29c111fcfba695b9ff4866f588f623117f010b7b5cc87c8974e27e7917966ddb9eda6e87eaadeb2c1b265dfaf3cd5ae58c92a2ea90fc9ae3ee17e
6
+ metadata.gz: ab0d20cb16a171f6b2e4cafec6d0fd5038994e28d1891753a89efceffeedb71bcf58370385fec709fab694f059111a3e1f4f829eb6eabbfe98d4ee5d17ed414f
7
+ data.tar.gz: 1234c97fb4ee02cf9cd3b85d5e5ff67ab6ce5ce12f73323b1bf961b4c9dea84c7240d0951dc05a6832669de4868953006e4d599595825262dc05612ca487978a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bbk-amqp (1.0.0.105683)
4
+ bbk-amqp (1.0.0.105723)
5
5
  activesupport (>= 6.0)
6
6
  bbk-utils (> 1.0.1)
7
7
  bunny (>= 2.19.0)
@@ -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
- message = [
19
- delivery_info,
20
- metadata.to_hash.with_indifferent_access,
21
- begin
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
- unblocker << message
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbk-amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.105683
4
+ version: 1.0.0.105723
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoylenko Yuri