eventq_rabbitmq 1.11.0 → 1.11.1

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
  SHA1:
3
- metadata.gz: 4928cde9bcd0b762d3b0938c52592048b21f2a58
4
- data.tar.gz: 42289c45561bc1f2258406ec33b07abadf8debb9
3
+ metadata.gz: 4d1f84071939202d7a6487fcac81399d9a473193
4
+ data.tar.gz: 72703a401e25627d44f2ef01bfe1411f2a3993a8
5
5
  SHA512:
6
- metadata.gz: 1aa81b43c8983ef50efc43426e1253f99410fd51433cfe5d8d4339296a5a0b24275760e8e385c85843e18a9b8c030fcce2775c2a4797aab89f7a61f9401c23f4
7
- data.tar.gz: 245391ae31872971615166e6e9bc90bfcc3d5f0cbe63c2cf6437c55c236adbb24f04db0c0c771a2a5986ed24a3825ef964979ccc3025a946c0cf5505a4838fe2
6
+ metadata.gz: 907d582a7afc9015386f885d6ac0f290b6a903c0da1326bbbe9bcc0fb6214be9ef48792ab563a521161288f02aba7822de28fa922088b8b79860f1ffbd3af63d
7
+ data.tar.gz: 81cdf1ac8d763aec08ce75f37b36dda8c08eff70a7ce34b2bd8fff559c3c55802facf2403a8c3f875735ccf4647e84173e33dffe1f2b74e299bf537c59edc76c
@@ -96,16 +96,8 @@ module EventQ
96
96
  has_received_message = thread_process_iteration(channel, manager, queue, block)
97
97
 
98
98
  rescue => e
99
- EventQ.logger.error "An unhandled error occurred. Error: #{e} | Backtrace: #{e.backtrace}"
100
-
101
- if @on_error_block
102
- EventQ.log(:debug, "[#{self.class}] - Executing on error block.")
103
- begin
104
- @on_error_block.call(e, message)
105
- rescue => e2
106
- EventQ.log(:error, "[#{self.class}] - An error occurred executing the on error block. Error: #{e2}")
107
- end
108
- end
99
+ EventQ.log(:error, "An unhandled error occurred. Error: #{e} | Backtrace: #{e.backtrace}")
100
+ call_on_error_block(error: e)
109
101
  end
110
102
 
111
103
  if channel != nil && channel.status != :closed
@@ -138,6 +130,19 @@ module EventQ
138
130
 
139
131
  end
140
132
 
133
+ def call_on_error_block(error:, message: nil)
134
+ if @on_error_block
135
+ EventQ.log(:debug, "[#{self.class}] - Executing on_error block.")
136
+ begin
137
+ @on_error_block.call(error, message)
138
+ rescue => e
139
+ EventQ.log(:error, "[#{self.class}] - An error occurred executing the on_error block. Error: #{e}")
140
+ end
141
+ else
142
+ EventQ.log(:debug, "[#{self.class}] - No on_error block specified to execute.")
143
+ end
144
+ end
145
+
141
146
  def gc_flush
142
147
  if Time.now - last_gc_flush > @gc_flush_interval
143
148
  GC.start
@@ -174,15 +179,7 @@ module EventQ
174
179
 
175
180
  rescue => e
176
181
  EventQ.log(:error, "[#{self.class}] - An error occurred attempting to process a message. Error: #{e} | Backtrace: #{e.backtrace}")
177
-
178
- if @on_error_block
179
- EventQ.log(:debug, "[#{self.class}] - Executing on error block.")
180
- begin
181
- @on_error_block.call(e)
182
- rescue => e2
183
- EventQ.log(:error, "[#{self.class}] - An error occurred executing the on error block. Error: #{e2}")
184
- end
185
- end
182
+ call_on_error_block(error: e)
186
183
  end
187
184
 
188
185
  return received
@@ -227,6 +224,32 @@ module EventQ
227
224
  return provider.serialize(msg)
228
225
  end
229
226
 
227
+ def call_on_retry_exceeded_block(message)
228
+ if @retry_exceeded_block != nil
229
+ EventQ.log(:debug, "[#{self.class}] - Executing on_retry_exceeded block.")
230
+ begin
231
+ @retry_exceeded_block.call(message)
232
+ rescue => e
233
+ EventQ.log(:error, "[#{self.class}] - An error occurred executing the on_retry_exceeded block. Error: #{e}")
234
+ end
235
+ else
236
+ EventQ.log(:debug, "[#{self.class}] - No on_retry_exceeded block specified.")
237
+ end
238
+ end
239
+
240
+ def call_on_retry_block(message)
241
+ if @on_retry_block
242
+ EventQ.log(:debug, "[#{self.class}] - Executing on_retry block.")
243
+ begin
244
+ @on_retry_block.call(message, abort)
245
+ rescue => e
246
+ EventQ.log(:error, "[#{self.class}] - An error occurred executing the on_retry block. Error: #{e}")
247
+ end
248
+ else
249
+ EventQ.log(:debug, "[#{self.class}] - No on_retry block specified.")
250
+ end
251
+ end
252
+
230
253
  def reject_message(channel, message, delivery_info, retry_exchange, queue, abort)
231
254
 
232
255
  EventQ.log(:info, "[#{self.class}] - Message rejected removing from queue.")
@@ -238,16 +261,7 @@ module EventQ
238
261
 
239
262
  EventQ.log(:info, "[#{self.class}] - Message retry attempt limit exceeded. Msg: #{serialize_message(message)}")
240
263
 
241
- if @retry_exceeded_block != nil
242
- EventQ.log(:debug, "[#{self.class}] - Executing retry exceeded block.")
243
- begin
244
- @retry_exceeded_block.call(message)
245
- rescue => e
246
- EventQ.log(:error, "[#{self.class}] - An error occurred executing the retry exceeded block. Error: #{e}")
247
- end
248
- else
249
- EventQ.log(:debug, "[#{self.class}] - No retry exceeded block specified.")
250
- end
264
+ call_on_retry_exceeded_block(message)
251
265
 
252
266
  #check if the message is allowed to be retried
253
267
  elsif queue.allow_retry
@@ -271,14 +285,7 @@ module EventQ
271
285
  retry_exchange.publish(serialize_message(message), :expiration => message_ttl)
272
286
  EventQ.log(:debug, "[#{self.class}] - Published message to retry exchange.")
273
287
 
274
- if @on_retry_block
275
- EventQ.log(:debug, "[#{self.class}] - Executing on retry block.")
276
- begin
277
- @on_retry_block.call(message, abort)
278
- rescue => e
279
- EventQ.log(:error, "[#{self.class}] - An error occurred executing the on retry block. Error: #{e}")
280
- end
281
- end
288
+ call_on_retry_block(message)
282
289
 
283
290
  end
284
291
 
@@ -351,6 +358,7 @@ module EventQ
351
358
  rescue => e
352
359
  EventQ.log(:error, "[#{self.class}] - An unhandled error happened attempting to process a queue message. Error: #{e} | Backtrace: #{e.backtrace}")
353
360
  error = true
361
+ call_on_error_block(error: e, message: message)
354
362
  end
355
363
 
356
364
  if error || abort
@@ -1,3 +1,3 @@
1
1
  module EventqRabbitmq
2
- VERSION = "1.11.0"
2
+ VERSION = "1.11.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler