istox 0.1.130.pre.2 → 0.1.130.pre.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -97,7 +97,7 @@ GEM
97
97
  ffi (1.12.2)
98
98
  globalid (0.4.2)
99
99
  activesupport (>= 4.2.0)
100
- google-protobuf (3.11.4-universal-darwin)
100
+ google-protobuf (3.11.4)
101
101
  googleapis-common-protos-types (1.0.4)
102
102
  google-protobuf (~> 3.0)
103
103
  graphlient (0.3.7)
@@ -108,7 +108,7 @@ GEM
108
108
  graphql-client (0.16.0)
109
109
  activesupport (>= 3.0)
110
110
  graphql (~> 1.8)
111
- grpc (1.27.0-universal-darwin)
111
+ grpc (1.27.0)
112
112
  google-protobuf (~> 3.11)
113
113
  googleapis-common-protos-types (~> 1.0)
114
114
  grpc-tools (1.27.0)
@@ -142,6 +142,12 @@ module Istox
142
142
  nil
143
143
  end
144
144
 
145
+ def queue_routing_key(consumer_key)
146
+ queue_config_from_consumer_key!(consumer_key)['routing_key'] || (queue_name consumer_key)
147
+ rescue
148
+ nil
149
+ end
150
+
145
151
  def queue_exclusive(consumer_key)
146
152
  queue_config_from_consumer_key!(consumer_key)['exclusive'] || false
147
153
  rescue
@@ -13,7 +13,7 @@ module Istox
13
13
  # publish_confirm: true/false
14
14
  # }
15
15
  def publish(exchange: nil, routing_key: nil, binding:nil, binding_suffix:nil, message:, options: {})
16
- log.debug '************************* Publish ************************'
16
+
17
17
  if exchange.nil? && routing_key.nil?
18
18
  raise 'Exchange and routing key cannot be nil at the same time.' if binding.nil?
19
19
  exchange = ::Istox::BunnyBoot.binding_exchange_id(binding)
@@ -24,7 +24,7 @@ module Istox
24
24
 
25
25
  exchange = ::Istox::BunnyBoot.search_exchange_of_routing_key!(routing_key) if routing_key.present? && exchange.nil?
26
26
  ex = exchange(exchange)
27
- options[:routing_key] = routing_key unless routing_key.nil?
27
+ options[:routing_key] = routing_key unless routing_key.nil? || options[:routing_key]
28
28
 
29
29
  do_publish ex, options, message
30
30
  end
@@ -197,7 +197,6 @@ module Istox
197
197
  end
198
198
 
199
199
  def do_publish(ex, options = {}, message)
200
- log.debug '************** do_publish ***************'
201
200
  eid = ::Istox::BunnyBoot.eid ex
202
201
  ch = ex.channel
203
202
  channel_id = ch.id
@@ -217,7 +216,6 @@ module Istox
217
216
  end
218
217
 
219
218
  if confirm && mode == 0
220
- log.debug '************** Confirm && mode == 0 ***************'
221
219
  success = ex.channel.wait_for_confirms
222
220
  if success
223
221
  # ::Istox::BunnyBoot.del_tracker_on_channel channel_id
@@ -233,7 +231,6 @@ module Istox
233
231
  ret
234
232
  end
235
233
  end
236
- log.debug '******************* End of do_publish ******************'
237
234
  rescue Bunny::ConnectionClosedError => e
238
235
  log.debug "Publish fails due to #{e}"
239
236
  sleep 1
@@ -76,7 +76,7 @@ module Istox
76
76
 
77
77
  # Bind queue to exchange
78
78
  queue_options = {}
79
- queue_options[:routing_key] = queue_name if exchange_type == 'direct' || exchange_type == 'topic'
79
+ queue_options[:routing_key] = ::Istox::BunnyBoot.queue_routing_key consumer_key if exchange_type == 'direct' || exchange_type == 'topic'
80
80
  queue.bind exchange, queue_options
81
81
  end
82
82
 
@@ -88,7 +88,7 @@ module Istox
88
88
  end
89
89
  retry_queue = active_channel.queue("#{queue_name}.retry", arguments: {
90
90
  'x-dead-letter-exchange': letter_exchange,
91
- 'x-dead-letter-routing-key': "#{queue_name}",
91
+ 'x-dead-letter-routing-key': ::Istox::BunnyBoot.queue_routing_key(consumer_key),
92
92
  'x-message-ttl': (::Istox::BunnyBoot.queue_retry_gap consumer_key)
93
93
  })
94
94
  unless exchange_name.nil?
@@ -163,7 +163,9 @@ module Istox
163
163
  log.debug "Consumer Retry count: #{retry_count}"
164
164
  # @option opts [Integer] :priority Message priority, 0 to 9. Not used by RabbitMQ, only applications
165
165
  # here we adopt the unused priority as remaining retry_count
166
- ::Istox::BunnyBoot.publish(exchange_retry, payload_object, routing_key: "#{queue_name}.retry", priority: retry_count, type: 'dlx')
166
+ ::Istox::BunnyBoot.publish(exchange_retry, processing_paylod, routing_key: "#{queue_name}.retry", priority: retry_count, type: 'dlx')
167
+ else
168
+ log.info ""
167
169
  end
168
170
  =begin
169
171
  # For redelivered message, call 'reject' not 'nack' in order to reschedule message to tail not head of queue
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.130.pre.2'.freeze
2
+ VERSION = '0.1.130.pre.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.130.pre.2
4
+ version: 0.1.130.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print