Class: Qwirk::Adapter::JMS::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/qwirk/adapter/jms/consumer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, options) ⇒ Consumer

Returns a new instance of Consumer.



8
9
10
11
12
13
14
# File 'lib/qwirk/adapter/jms/consumer.rb', line 8

def initialize(connection, options)
  @options = options
  @session = connection.create_session
  @consumer = @session.consumer(@options)
  @session.start
  @stopped = false
end

Instance Attribute Details

#stoppedObject (readonly)

Returns the value of attribute stopped.



6
7
8
# File 'lib/qwirk/adapter/jms/consumer.rb', line 6

def stopped
  @stopped
end

Instance Method Details

#acknowledge_messageObject



22
23
24
# File 'lib/qwirk/adapter/jms/consumer.rb', line 22

def acknowledge_message
  @message.acknowledge
end

#receiveObject



16
17
18
19
20
# File 'lib/qwirk/adapter/jms/consumer.rb', line 16

def receive
  @message = @consumer.receive
  return nil unless @message
  return Util.parse_response(@message)
end

#stopObject



26
27
28
29
30
31
32
33
# File 'lib/qwirk/adapter/jms/consumer.rb', line 26

def stop
  return if @stopped
  Qwirk.logger.info "Stopping consumer for #{@options.inspect}"
  # Don't clobber the session before a reply
  @consumer.close if @consumer
  @session.close if @session
  @stopped = true
end