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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c7a6743f37e74634e75f4035eb7154a37acabfdc2a7b4c89122fe74a2d428b0
4
- data.tar.gz: f37fda540ff9534e45d0d5f7574a2fabb425419ec0fcaba019bf54a7de9b49bb
3
+ metadata.gz: b795df145f589a12ff12bb34e6f22652edfdfa4223936b5b50126102a161706e
4
+ data.tar.gz: 7e7bc1ae16fcf85e170d6d80eac94c49f825ae2e068a8d0852844dbf3fada0ce
5
5
  SHA512:
6
- metadata.gz: 31eecbb42e6a01ce73e59cee84b47a03948e68c82189c3d1ff628a3a0e3d389467a2c203a16747dcb3d2ade159b120b32b36c40554628eac59878117f73607ed
7
- data.tar.gz: 5f2ababd39ba07ae06db495dc5dec1c36dd7f3879d89f85f9183cffdb3696b6980f0bf6a079179b55c48fb01a3d47169545feb75734e203cf179e874c68ec6a4
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.0.0.152789)
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.15.0)
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.2)
108
+ set (1.0.3)
109
109
  sexp_processor (4.16.0)
110
110
  simplecov (0.21.2)
111
111
  docile (~> 1.1)
@@ -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)
@@ -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 }
@@ -3,7 +3,7 @@
3
3
  module BBK
4
4
  module AMQP
5
5
 
6
- VERSION = '1.0.0'
6
+ VERSION = '1.1.0'
7
7
 
8
8
  end
9
9
  end
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.0.0.152789
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-06-19 00:00:00.000000000 Z
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.32
250
+ rubygems_version: 3.2.33
251
251
  signing_key:
252
252
  specification_version: 4
253
253
  summary: AMQP interaction classes for BBK stack