lib/amq/openamq.rb
# Takes all the arguments that publish method takes. In addition, timeout
# (in seconds) for waiting for reply can be specified
Takes all the arguments that publish method takes. In addition, timeout
(in seconds) for waiting for reply can be specified
Takes all the arguments that publish method takes . In addition timeout ( in seconds ) for waiting for reply can be specified
def request(args)
      args = args.dup
      args[:immediate] = false
      args[:mandatory] = true
      consumer_tag = nil
      queue = declare_and_bind_private_queue()
      args[:reply_to] = queue
      publish(args)
      args[:timeout] ||= 500
      consume(:queue     => queue,
              :exclusive => true)
      consumer_tag = @sess.consumer_tag
      rc = wait(args[:timeout])
      if rc == 0
        if basic_returned_count > 0
          raise AMQError.new("Failed to send request.  Message returned from broker.")
        end
        if basic_arrived_count == 0
          return :timeout
        end
        return basic_arrived.body
      else
        raise AMQError.new("Failed.  Interrupted while waiting for response.")
      end
    ensure
      @sess.basic_cancel(consumer_tag) if consumer_tag
    end
def request ( args ) args = args . dup args [ :immediate ] = false args [ :mandatory ] = true consumer_tag = nil queue = declare_and_bind_private_queue ( ) args [ :reply_to ] = queue publish ( args ) args [ :timeout ] ||= 500 consume ( :queue => queue , :exclusive => true ) consumer_tag = @sess . consumer_tag rc = wait ( args [ :timeout ] ) if rc == 0 if basic_returned_count > 0 raise AMQError . new ( "Failed to send request.  Message returned from broker." ) end if basic_arrived_count == 0 return :timeout end return basic_arrived . body else raise AMQError . new ( "Failed.  Interrupted while waiting for response." ) end ensure @sess . basic_cancel ( consumer_tag ) if consumer_tag end
Takes all the arguments that publish method takes.
Takes all the arguments that publish method takes .
# Create a private reply queue # Send out the request # Listen for the reply msg(s)
args
<not_specific>