Class: RabbitWQ::MessageHandler

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Queues, WorkLogging, Servitude::ConfigHelper, Servitude::Logging
Defined in:
lib/rabbit_wq/message_handler.rb

Constant Summary collapse

REQUEUE =
true

Instance Method Summary collapse

Instance Method Details

#call(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rabbit_wq/message_handler.rb', line 16

def call( options )
  Time.zone = config.time_zone

  channel       = options[:channel]
  delivery_info = options[:delivery_info]
        = options[:metadata]
  payload       = options[:payload]

  worker = deserialize_worker( payload )
  info Rainbow( "WORKER [#{worker.object_id}] " + worker.inspect ).yellow
  handle_work( worker, payload )
  try_on_success_callback( worker )
  channel.ack delivery_info.delivery_tag
rescue => e
  handle_error( worker, e, channel, delivery_info, payload,  )
end