Sha256: 5a83f60015b1008fe1866e2758ddc6ea49190626894e3d779b079f0fdf029e45

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

module HornetQ::Client

  # Send a request to a server and wait for a reply  
  class Requestor
    def initialize(session, request_address)
      @session = session
      @producer = session.create_producer(request_address)
      reply_queue = "#{request_address}.#{Java::java.util::UUID.randomUUID.toString}"
      begin
        session.create_temporary_queue(reply_queue, reply_queue)
      rescue NativeException => exc
        p exc
      end
      @consumer = session.create_consumer(reply_queue)
    end
  
    def request(request_message, timeout)
      request_message.putStringProperty(Java::OrgHornetqCoreClientImpl::ClientMessageImpl::REPLYTO_HEADER_NAME, @consumer.queue_name);
      @producer.send(request_message)
      @consumer.receive(timeout)
    end
    
    def close
      @producer.close if @producer
      @consumer.close if @consumer
      @session.delete_queue(@consumer.queue_name)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jruby-hornetq-0.2.3.alpha lib/hornetq/client/requestor.rb
jruby-hornetq-0.2.1.alpha lib/hornetq/client/requestor.rb