Class: MicroQ::Middleware::Server::Retry

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/micro_q/middleware/server/retry.rb

Overview

Capture, re-raise and potentially push a modified message back onto the queue. We add metadata about the retry into the ‘retried’ key to track the attempts.

count: The number of retires thus far at: When the last retry occurred when: The time at which the message will be retried again

Constant Summary collapse

RETRY =
proc {|klass| klass ? "messages:#{klass}:retry" : 'messages:retry' }

Instance Method Summary collapse

Methods included from Util

#statistics, #stats_incr

Instance Method Details

#call(worker, message) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/micro_q/middleware/server/retry.rb', line 18

def call(worker, message)
  yield
rescue Exception => e
  raise e unless message['retry']

  retried!(message)
  stats(message)

  unless message['retried']['count'] > retry_count(message)
    MicroQ.push(message, message['retried'])
  end

  raise e
end