Sha256: 815d9f798a32afe1ab72062123b11c1281e4b7e78c29a7e14b31dbc5f5a52c92

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 Bytes

Contents

module BunnyCarrot
  class BusinessActorObserver
    include BunnyCarrot::Logger

    def self.update(time, message_args, result, exception)
      message = message_args.first
      logger.info "Observing business..."
      if result
        message.fetch(:acknowledge_proc).call
        logger.info 'Message is acknowledged'
      else
        logger.info "Rejected because of: #{exception.inspect}"
        message_attrs = Hamster.hash({ queue_name:       message.fetch(:queue_name),
                                       payload:          message.fetch(:payload),
                                       message_headers:  message.fetch(:message_headers),
                                       acknowledge_proc: message.fetch(:acknowledge_proc) })
        worker        = message.fetch(:worker)
        logger.info 'Defining exception handling strategy...'
        strategy = worker.strategy(message_attrs, exception)
        strategy.perform
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bunny_carrot-0.0.2 lib/bunny_carrot/business_actor_observer.rb