Class: RosettaQueue::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/rosetta_queue/consumer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_handler) ⇒ Consumer

Returns a new instance of Consumer.



18
19
20
# File 'lib/rosetta_queue/consumer.rb', line 18

def initialize(message_handler)
  @message_handler = message_handler
end

Class Method Details

.delete(destination, options = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/rosetta_queue/consumer.rb', line 11

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

.receive(destination, options = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/rosetta_queue/consumer.rb', line 4

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

Instance Method Details

#receiveObject



22
23
24
25
26
27
# File 'lib/rosetta_queue/consumer.rb', line 22

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