bbk-amqp 1.0.0.152789 → 1.1.0.199380
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/bbk/amqp/consumer.rb +13 -1
- data/lib/bbk/amqp/publisher.rb +1 -2
- data/lib/bbk/amqp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b795df145f589a12ff12bb34e6f22652edfdfa4223936b5b50126102a161706e
|
4
|
+
data.tar.gz: 7e7bc1ae16fcf85e170d6d80eac94c49f825ae2e068a8d0852844dbf3fada0ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e44e7227e9d00acf3d163fd7f8c47c18582cd0874782b48ebe5a3a1401c67090e9e50aa5a297bae3485ed0ab0ce139b5cdc22fba890892e8ce4efcee838f5911
|
7
|
+
data.tar.gz: 7debad965b8ed99fc1a97ca029566a3230952317ba7b92c989edf7053eeb847f753c7e49b323c20703b3ea9818ded004f839a490a2cec7cf26125d43736a2848
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bbk-amqp (1.
|
4
|
+
bbk-amqp (1.1.0.199380)
|
5
5
|
activesupport (>= 6.0)
|
6
6
|
bbk-utils (> 1.0.1)
|
7
7
|
bunny (>= 2.19.0)
|
@@ -63,7 +63,7 @@ GEM
|
|
63
63
|
launchy (2.5.0)
|
64
64
|
addressable (~> 2.7)
|
65
65
|
minitest (5.15.0)
|
66
|
-
oj (3.
|
66
|
+
oj (3.16.1)
|
67
67
|
parser (3.0.3.2)
|
68
68
|
ast (~> 2.4.1)
|
69
69
|
path_expander (1.1.0)
|
@@ -105,7 +105,7 @@ GEM
|
|
105
105
|
virtus (~> 1.0)
|
106
106
|
russian (0.6.0)
|
107
107
|
i18n (>= 0.5.0)
|
108
|
-
set (1.0.
|
108
|
+
set (1.0.3)
|
109
109
|
sexp_processor (4.16.0)
|
110
110
|
simplecov (0.21.2)
|
111
111
|
docile (~> 1.1)
|
data/lib/bbk/amqp/consumer.rb
CHANGED
@@ -6,6 +6,7 @@ module BBK
|
|
6
6
|
class Consumer
|
7
7
|
|
8
8
|
attr_reader :connection, :queue_name, :queue, :rejection_policy, :options, :logger
|
9
|
+
attr_accessor :publisher
|
9
10
|
|
10
11
|
DEFAULT_OPTIONS = {
|
11
12
|
consumer_pool_size: 3,
|
@@ -17,10 +18,11 @@ module BBK
|
|
17
18
|
|
18
19
|
PROTOCOLS = %w[mq amqp amqps].freeze
|
19
20
|
|
20
|
-
def initialize(connection, queue_name: nil, **options)
|
21
|
+
def initialize(connection, queue_name: nil, publisher: nil, **options)
|
21
22
|
@connection = connection
|
22
23
|
@channel = options.delete(:channel)
|
23
24
|
@queue = options.delete(:queue)
|
25
|
+
@publisher = publisher
|
24
26
|
|
25
27
|
if @queue.nil? && queue_name.nil?
|
26
28
|
raise ArgumentError.new('queue_name or queue must be provided!')
|
@@ -79,10 +81,20 @@ module BBK
|
|
79
81
|
# [] - для работы тестов. В реальности вернется объект VersionedDeliveryTag у
|
80
82
|
# которого to_i (вызывается внутри channel.ack) вернет фактическоe число
|
81
83
|
# logger.debug "Ack message #{incoming.headers[:type]}[#{incoming.headers[:message_id]}] on channel: #{incoming.delivery_info[:channel]&.id}[#{incoming.delivery_info[:channel]&.object_id}] delivery tag: #{incoming.delivery_info[:delivery_tag].to_i}"
|
84
|
+
send_answer(incoming, answer) unless answer.nil?
|
82
85
|
logger.debug "Ack message #{incoming.headers[:type]}[#{incoming.headers[:message_id]}] delivery tag: #{incoming.delivery_info[:delivery_tag].to_i}"
|
83
86
|
incoming.delivery_info[:channel].ack incoming.delivery_info[:delivery_tag]
|
84
87
|
end
|
85
88
|
|
89
|
+
protected def send_answer(incoming, answer)
|
90
|
+
if publisher.nil?
|
91
|
+
logger.error "Can't answer message: empty publisher"
|
92
|
+
raise "Publisher not configured in consumer #{self.inspect}"
|
93
|
+
end
|
94
|
+
logger.debug "Send answer message for incoming(message_id=#{incoming.message_id}) to #{answer.route}"
|
95
|
+
publisher.publish(answer).value!
|
96
|
+
end
|
97
|
+
|
86
98
|
# Nack incoming message
|
87
99
|
# @param incoming [BBK::AMQP::Message] nack procesing message
|
88
100
|
def nack(incoming, *args, error: nil, **_kwargs)
|
data/lib/bbk/amqp/publisher.rb
CHANGED
@@ -120,8 +120,7 @@ module BBK
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def on_return(exchange, basic_return, properties, body)
|
123
|
-
args = { exchange: exchange, basic_return: basic_return, properties: properties,
|
124
|
-
body: body }
|
123
|
+
args = { exchange: exchange, basic_return: basic_return, properties: properties, body: body }
|
125
124
|
message_id = properties[:message_id]
|
126
125
|
logger.info "Message with message_id #{message_id} returned #{basic_return.inspect}"
|
127
126
|
ack_id, = ack_map.each_pair.find {|_, msg_id| msg_id == message_id }
|
data/lib/bbk/amqp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbk-amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0.199380
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoylenko Yuri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
- !ruby/object:Gem::Version
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
|
-
rubygems_version: 3.2.
|
250
|
+
rubygems_version: 3.2.33
|
251
251
|
signing_key:
|
252
252
|
specification_version: 4
|
253
253
|
summary: AMQP interaction classes for BBK stack
|