Class: Shoryuken::Processor::MessageVisibilityExtender

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Util
Defined in:
lib/shoryuken/processor.rb

Instance Method Summary collapse

Methods included from Util

#elapsed, #fire_event, #logger, #unparse_queues, #watchdog, #worker_name

Instance Method Details

#auto_extend(queue, sqs_msg, worker_class) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/shoryuken/processor.rb', line 40

def auto_extend(queue, sqs_msg, worker_class)
  queue_visibility_timeout = Shoryuken::Client.queues(queue).visibility_timeout

  every(queue_visibility_timeout - 5) do
    begin
      logger.debug { "Extending message #{worker_name(worker_class, sqs_msg)}/#{queue}/#{sqs_msg.message_id} visibility timeout by #{queue_visibility_timeout}s." }

      sqs_msg.visibility_timeout = queue_visibility_timeout
    rescue => e
      logger.error { "Could not auto extend the message #{worker_class}/#{queue}/#{sqs_msg.message_id} visibility timeout. Error: #{e.message}" }
    end
  end
end