Class: RabbitMQClient::QueueConsumer

Inherits:
DefaultConsumer
  • Object
show all
Defined in:
lib/rabbitmq_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(channel, block) ⇒ QueueConsumer

Returns a new instance of QueueConsumer.



23
24
25
26
27
# File 'lib/rabbitmq_client.rb', line 23

def initialize(channel, block)
  @channel = channel
  @block = block
  super(channel)
end

Instance Method Details

#handleDelivery(consumer_tag, envelope, properties, body) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/rabbitmq_client.rb', line 29

def handleDelivery(consumer_tag, envelope, properties, body)
  delivery_tag = envelope.get_delivery_tag
  message_body = Marshal.load(String.from_java_bytes(body))
  # TODO: Do we need to do something with properties?
  @block.call message_body
  @channel.basic_ack(delivery_tag, false)
end