Sha256: f71983d706bc2502c2f5f71f95cd4f4b19520de695e7368fd7b17d1449c82f4f

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

module HornetQClient

  # Send a request to a server and wait for a reply  
  class ClientRequestor
    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

1 entries across 1 versions & 1 rubygems

Version Path
jruby-hornetq-0.2.0.alpha lib/hornetq/client_requestor.rb