Sha256: fc639dc931285bc3722bcb7e0ea2b5cee1c2616e24cfea917256e1f8cf27231b

Contents?: true

Size: 994 Bytes

Versions: 2

Compression:

Stored size: 994 Bytes

Contents

module RosettaQueue
  class Consumer

    def self.receive(destination, options = {})
      RosettaQueue::Adapter.open { |a| return a.receive_once(Destinations.lookup(destination), options) }

    rescue Exception=>e
        RosettaQueue.logger.error("Caught exception in Consumer.receive: #{$!}\n" + e.backtrace.join("\n\t"))
    end

    def self.delete(destination, options={})
      RosettaQueue::Adapter.open { |a| a.delete(Destinations.lookup(destination), options)}

      rescue Exception=>e
        RosettaQueue.logger.error("Caught exception in Consumer.delete: #{$!}\n" + e.backtrace.join("\n\t"))
    end

    def initialize(message_handler)
      @message_handler = message_handler
    end

    def receive
      connection.receive_with(@message_handler)

      rescue Exception=>e
        RosettaQueue.logger.error("Caught exception in Consumer#receive: #{$!}\n" + e.backtrace.join("\n\t"))
    end

    private

    def connection
      @conn ||= Adapter.open
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rosetta_queue-0.5.2 lib/rosetta_queue/consumer.rb
rosetta_queue-0.5.0 lib/rosetta_queue/consumer.rb