lib/wookie/handlers.rb
# Uses the x-death header to determine the number of failures this job has
# seen in the past. This does not count the current failure. So for
# instance, the first time the job fails, this will return 0, the second
# time, 1, etc.
# @param headers [Hash] Hash of headers that Rabbit delivers as part of
#   the message
# @return [Integer] Count of number of failures.
Uses the x-death header to determine the number of failures this job has
seen in the past. This does not count the current failure. So for
instance, the first time the job fails, this will return 0, the second
time, 1, etc.
Uses the x - death header to determine the number of failures this job has seen in the past . This does not count the current failure . So for instance the first time the job fails this will return 0 the second time 1 etc .
def failure_count(headers)
      if headers.nil? || headers['x-death'].nil?
        0
      else
        x_death_array = headers['x-death'].select do |x_death|
          x_death['queue'] == @worker_queue_name
        end
        if x_death_array.count > 0 && x_death_array.first['count']
          x_death_array.inject(0) {|sum, x_death| sum + x_death['count']}
        else
          x_death_array.count
        end
      end
    end
def failure_count ( headers ) if headers . nil? || headers [ 'x-death' ] . nil? 0 else x_death_array = headers [ 'x-death' ] . select do | x_death | x_death [ 'queue' ] == @worker_queue_name end if x_death_array . count > 0 && x_death_array . first [ 'count' ] x_death_array . inject ( 0 ) { | sum , x_death | sum + x_death [ 'count' ] } else x_death_array . count end end end
Uses the x-death header to determine the number of failures this job has
seen in the past.
Uses the x - death header to determine the number of failures this job has seen in the past .
# Newer versions of RabbitMQ return headers with a count key # Older versions return a separate x-death header for each failure
Count of number of failures.
Count of number of failures .
Integer
headers
Hash of headers that Rabbit delivers as part of the message
Hash of headers that Rabbit delivers as part of the message