istox 0.1.130.pre.3 → 0.1.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.130.pre.2)
4
+ istox (0.1.130)
5
5
  awesome_print
6
6
  binding_of_caller
7
7
  bunny (>= 2.12.0)
@@ -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)
100
+ google-protobuf (3.11.4-universal-darwin)
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)
111
+ grpc (1.27.0-universal-darwin)
112
112
  google-protobuf (~> 3.11)
113
113
  googleapis-common-protos-types (~> 1.0)
114
114
  grpc-tools (1.27.0)
@@ -118,7 +118,6 @@ module Istox
118
118
 
119
119
  name = "#{prefix}#{delimiter}#{name}" unless prefix.nil?
120
120
  name = "#{name}#{delimiter}#{suffix}" unless suffix.nil?
121
- log.debug "name is #{name}"
122
121
  name
123
122
  rescue
124
123
  nil
@@ -281,9 +280,9 @@ module Istox
281
280
  # But each retry, there is new delivery_tag that should be updated
282
281
  id = "#{channel_id.to_s}:#{delivery_tag.to_s}"
283
282
 
284
- ::Istox::RedisBoot.sets("#{id}:payload", payload.to_s, 4)
283
+ ::Istox::RedisBoot.sets("#{id}:payload", JSON.dump(payload), 4)
285
284
  ::Istox::RedisBoot.sets("#{id}:eid", eid.to_s, 4)
286
- ::Istox::RedisBoot.sets("#{id}:options", options.to_s, 4)
285
+ ::Istox::RedisBoot.sets("#{id}:options", JSON.dump(options), 4)
287
286
  end
288
287
 
289
288
  def find_tracker_on_channel(channel_id, delivery_tag, key)
@@ -320,6 +319,10 @@ module Istox
320
319
  ex.type
321
320
  end
322
321
 
322
+ def cacheMsg(suffix, msg)
323
+ ::Istox::RedisBoot.sets("drop_msg_#{suffix}", JSON.dump(msg), 7)
324
+ end
325
+
323
326
  private
324
327
 
325
328
  def data
@@ -26,9 +26,6 @@ module Istox
26
26
  subject: subject || 'Message from iSTOX',
27
27
  body: content
28
28
  }
29
- },
30
- options: {
31
- confirm: 0
32
29
  }
33
30
  )
34
31
  end
@@ -54,9 +51,6 @@ module Istox
54
51
  template_name: template_name,
55
52
  template_data_arr_json: template_data_arr.to_json
56
53
  }
57
- },
58
- options: {
59
- confirm: 0
60
54
  }
61
55
  )
62
56
  end
@@ -92,9 +86,6 @@ module Istox
92
86
  body: content,
93
87
  attachments_json: attachments&.to_json
94
88
  }
95
- },
96
- options: {
97
- confirm: 0
98
89
  }
99
90
  )
100
91
  end
@@ -126,9 +117,6 @@ module Istox
126
117
  template_data_arr_json: template_data_arr.to_json,
127
118
  attachments_json: attachments&.to_json
128
119
  }
129
- },
130
- options: {
131
- confirm: 0
132
120
  }
133
121
  )
134
122
  end
@@ -87,7 +87,7 @@ module Istox
87
87
  ::Istox::BunnyBoot.del_tracker_on_channel @channel[threadId]['confirm-1'].id
88
88
  else
89
89
  @channel[threadId]['confirm-1'].nacked_set.each do |n|
90
- log.debug "[Async #{threadId}] Confirm mode UnAcked Delivery Tag: #{n}"
90
+ log.debug("Publish Error[Async #{threadId}]: UNACK delivery tag is #{n}, republish message")
91
91
  eid = ::Istox::BunnyBoot.find_tracker_on_channel @channel[threadId]['confirm-1'].id, n, 'eid'
92
92
  payload = ::Istox::BunnyBoot.find_tracker_on_channel @channel[threadId]['confirm-1'].id, n, 'payload'
93
93
  payload = JSON.dump payload unless payload.nil?
@@ -218,17 +218,15 @@ module Istox
218
218
  if confirm && mode == 0
219
219
  success = ex.channel.wait_for_confirms
220
220
  if success
221
- # ::Istox::BunnyBoot.del_tracker_on_channel channel_id
222
- 0
221
+ ::Istox::BunnyBoot.del_tracker_on_channel channel_id
223
222
  else
224
- ret = []
225
223
  ex.channel.nacked_set.each do |n|
226
- log.debug("UnAck delivery tag is #{n}")
224
+ log.debug("Publish Error: UNACK delivery tag is #{n}, republish message")
227
225
  options = ::Istox::BunnyBoot.find_tracker_on_channel(channel_id, n, 'options')
228
- options = JSON.dump options
229
- ret << {delivery_tag: n, message_id: options[:message_id]}
226
+ options = JSON.parse(options, :symbolize_names => true)
227
+ options[:delivery_tag] = n
228
+ do_publish(ex, options, message)
230
229
  end
231
- ret
232
230
  end
233
231
  end
234
232
  rescue Bunny::ConnectionClosedError => e
@@ -236,7 +234,7 @@ module Istox
236
234
  sleep 1
237
235
  do_publish(ex,options,message)
238
236
  rescue => e
239
- log.debug "Timeout error happens #{e}"
237
+ log.debug "Error happens: #{e}"
240
238
  end
241
239
  end
242
240
  end
@@ -76,7 +76,7 @@ module Istox
76
76
 
77
77
  # Bind queue to exchange
78
78
  queue_options = {}
79
- queue_options[:routing_key] = ::Istox::BunnyBoot.queue_routing_key consumer_key if exchange_type == 'direct' || exchange_type == 'topic'
79
+ queue_options[:routing_key] = queue_name 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': ::Istox::BunnyBoot.queue_routing_key(consumer_key),
91
+ 'x-dead-letter-routing-key': "#{queue_name}",
92
92
  'x-message-ttl': (::Istox::BunnyBoot.queue_retry_gap consumer_key)
93
93
  })
94
94
  unless exchange_name.nil?
@@ -115,7 +115,7 @@ module Istox
115
115
  # Initiate klass
116
116
  ruby_class = ::Istox::BunnyBoot.ruby_class consumer_key
117
117
  @workers = {} if @workers.nil?
118
- unless ruby_class.nil? || @workers[ruby_class]
118
+ unless block || @workers[ruby_class]
119
119
  klass = Object.const_get(
120
120
  '::' + (ruby_class.nil? ? "#{consumer_key.to_s.underscore}_consumer" : ruby_class).camelize
121
121
  )
@@ -134,7 +134,6 @@ module Istox
134
134
  log.debug "Delivery_info: #{delivery_info}"
135
135
  log.debug "Metadata: #{metadata}"
136
136
  log.debug "Payload: #{payload}"
137
- log.debug "Redelivered Message?: #{delivery_info.redelivered}"
138
137
 
139
138
  # For retried message, if reaching retry count limit, return ack anyway
140
139
  # If retry limit is -1, no retry limit
@@ -144,12 +143,13 @@ module Istox
144
143
  processing_paylod = JSON.parse(payload)
145
144
  processing_paylod = ::Istox::CommonHelper.to_open_struct(processing_paylod) if ::Istox::BunnyBoot.queue_worker_param_format(consumer_key) == 'open_struct'
146
145
  log.info "Processing in consumer: #{klass}, paylod: #{processing_paylod.to_h.inspect}"
147
-
148
146
  if @workers[ruby_class].nil?
149
147
  result = block.call(processing_paylod, metadata, delivery_info) unless block.nil?
150
148
  else
151
149
  result = @workers[ruby_class].process(processing_paylod, metadata, delivery_info)
152
150
  end
151
+ else
152
+ ::Istox::BunnyBoot.cacheMsg(Time.now.to_s, {queue: queue.name, payload: payload})
153
153
  end
154
154
  # active_channel.ack(delivery_info.delivery_tag) if manual_ack
155
155
  rescue StandardError => e
@@ -164,8 +164,6 @@ module Istox
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
166
  ::Istox::BunnyBoot.publish(exchange_retry, processing_paylod, routing_key: "#{queue_name}.retry", priority: retry_count, type: 'dlx')
167
- else
168
- log.info ""
169
167
  end
170
168
  =begin
171
169
  # For redelivered message, call 'reject' not 'nack' in order to reschedule message to tail not head of queue
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.130.pre.3'.freeze
2
+ VERSION = '0.1.130'.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.3
4
+ version: 0.1.130
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-20 00:00:00.000000000 Z
11
+ date: 2020-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -442,9 +442,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
442
442
  version: '0'
443
443
  required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  requirements:
445
- - - ">"
445
+ - - ">="
446
446
  - !ruby/object:Gem::Version
447
- version: 1.3.1
447
+ version: '0'
448
448
  requirements: []
449
449
  rubygems_version: 3.0.8
450
450
  signing_key: