Method: Beetle::Message#process

Defined in:
lib/beetle/message.rb

#process(handler) ⇒ Object

process this message and do not allow any exception to escape to the caller



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/beetle/message.rb', line 261

def process(handler)
  result = nil
  begin
    # pre_process might set up log routing and it might raise
    handler.pre_process(self)
  rescue Exception => @pre_exception
    Beetle::reraise_expectation_errors!
    logger.error "Beetle: preprocessing error #{@pre_exception.class}(#{@pre_exception}) for #{msg_id}"
  end
  logger.debug "Beetle: processing message #{msg_id}(#{timestamp}) redelivered: #{header.redelivered?}"
  begin
    result = process_internal(handler)
    handler.process_exception(@exception || @pre_exception) if (@exception || @pre_exception)
    handler.process_failure(result) if result.failure?
  rescue Exception => e
    Beetle::reraise_expectation_errors!
    logger.warn "Beetle: exception '#{e}' during processing of message #{msg_id}"
    logger.warn "Beetle: backtrace: #{e.backtrace.join("\n")}"
    result = RC::InternalError
  end
  result
end