eventq_rabbitmq 1.10.4 → 1.11.0

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: 1e56bd84cbee6f49b6dead60a68cb600092fa0e5
4
- data.tar.gz: 7a08b8efdd47ead507c90649449a6599d095d224
3
+ metadata.gz: 4928cde9bcd0b762d3b0938c52592048b21f2a58
4
+ data.tar.gz: 42289c45561bc1f2258406ec33b07abadf8debb9
5
5
  SHA512:
6
- metadata.gz: 20709f9bd6255ecb6c50cc74e71bef1bffdb4ce00ffc23655abf4d537aaa2827dc8413a226fd78bff6ed2f5d817cb208c806d5a06acd958dde21b1624fd79338
7
- data.tar.gz: 86049fb088de5e4103aa8a80d5b5838f281305217e8497170d0d9204cd67d638a043bd6ad38b3ac99dc676a1830e549a7f22e282b46fb3bb9b3761c6e932d880
6
+ metadata.gz: 1aa81b43c8983ef50efc43426e1253f99410fd51433cfe5d8d4339296a5a0b24275760e8e385c85843e18a9b8c030fcce2775c2a4797aab89f7a61f9401c23f4
7
+ data.tar.gz: 245391ae31872971615166e6e9bc90bfcc3d5f0cbe63c2cf6437c55c236adbb24f04db0c0c771a2a5986ed24a3825ef964979ccc3025a946c0cf5505a4838fe2
@@ -11,6 +11,8 @@ module EventQ
11
11
  @is_running = false
12
12
 
13
13
  @retry_exceeded_block = nil
14
+ @on_retry_block = nil
15
+ @on_error_block = nil
14
16
  @hash_helper = HashKit::Helper.new
15
17
  @serialization_provider_manager = EventQ::SerializationProviders::Manager.new
16
18
  @last_gc_flush = Time.now
@@ -94,7 +96,16 @@ module EventQ
94
96
  has_received_message = thread_process_iteration(channel, manager, queue, block)
95
97
 
96
98
  rescue => e
97
- EventQ.logger.error "An unhandled error occurred attempting to communicate with RabbitMQ. Error: #{e} | Backtrace: #{e.backtrace}"
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
98
109
  end
99
110
 
100
111
  if channel != nil && channel.status != :closed
@@ -162,7 +173,16 @@ module EventQ
162
173
  end
163
174
 
164
175
  rescue => e
165
- EventQ.log(:error, "[#{self.class}] - An error occurred attempting to pop a message from the queue. Error: #{e} | Backtrace: #{e.backtrace}")
176
+ 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
166
186
  end
167
187
 
168
188
  return received
@@ -183,6 +203,16 @@ module EventQ
183
203
  return nil
184
204
  end
185
205
 
206
+ def on_retry(&block)
207
+ @on_retry_block = block
208
+ return nil
209
+ end
210
+
211
+ def on_error(&block)
212
+ @on_error_block = block
213
+ return nil
214
+ end
215
+
186
216
  def running?
187
217
  return @is_running
188
218
  end
@@ -197,7 +227,7 @@ module EventQ
197
227
  return provider.serialize(msg)
198
228
  end
199
229
 
200
- def reject_message(channel, message, delivery_info, retry_exchange, queue)
230
+ def reject_message(channel, message, delivery_info, retry_exchange, queue, abort)
201
231
 
202
232
  EventQ.log(:info, "[#{self.class}] - Message rejected removing from queue.")
203
233
  #reject the message to remove from queue
@@ -210,7 +240,11 @@ module EventQ
210
240
 
211
241
  if @retry_exceeded_block != nil
212
242
  EventQ.log(:debug, "[#{self.class}] - Executing retry exceeded block.")
213
- @retry_exceeded_block.call(message)
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
214
248
  else
215
249
  EventQ.log(:debug, "[#{self.class}] - No retry exceeded block specified.")
216
250
  end
@@ -237,6 +271,15 @@ module EventQ
237
271
  retry_exchange.publish(serialize_message(message), :expiration => message_ttl)
238
272
  EventQ.log(:debug, "[#{self.class}] - Published message to retry exchange.")
239
273
 
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
282
+
240
283
  end
241
284
 
242
285
  return true
@@ -312,7 +355,7 @@ module EventQ
312
355
 
313
356
  if error || abort
314
357
  EventQ::NonceManager.failed(message.id)
315
- reject_message(channel, message, delivery_info, retry_exchange, queue)
358
+ reject_message(channel, message, delivery_info, retry_exchange, queue, abort)
316
359
  else
317
360
  EventQ::NonceManager.complete(message.id)
318
361
  end
@@ -1,3 +1,3 @@
1
1
  module EventqRabbitmq
2
- VERSION = "1.10.4"
2
+ VERSION = "1.11.0"
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.10.4
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler