lib/isono/node_modules/rpc_channel.rb
# Publish a RPC request asynchronously.
# @param [RequestContext] req Request context object to be
# sent. If the context's state is not :init, it will fail.
Publish a RPC request asynchronously.
Publish a RPC request asynchronously .
def send_request(req)
        raise TypeError if !req.is_a?(RequestContext)
        raise "Request context seems to be sent already: #{req.state}" if req.state != :init
        if req.timeout_sec == -1.0
          req.timeout_sec = config_section.timeout_sec
        end
        req.process_event(:on_ready)
        EventMachine.schedule {
          @stats[:total_request_count] += 1
          if @stats[:peak_wait_response_size] < @active_requests.size
            @stats[:peak_wait_response_size] = @active_requests.size
          end
          if !req.oneshot
            @active_requests[req.ticket] = req
          end
          amq.queue(endpoint_queue_name(req.endpoint), {:exclusive=>false, :auto_delete=>true})
          @requested_endpoints[req.endpoint] = 1
          amq.default_exchange.publish(Serializer.instance.marshal(req.request_hash),
                                       {:message_id => req.ticket,
                                         :key => endpoint_queue_name(req.endpoint),
                                         :reply_to=>"command-recv.#{manifest.node_id}"}
                                       )
          req.process_event(:on_sent)
        }
      end
def send_request ( req ) raise TypeError if ! req . is_a? ( RequestContext ) raise "Request context seems to be sent already: #{req.state}" if req . state != :init if req . timeout_sec == - 1.0 req . timeout_sec = config_section . timeout_sec end req . process_event ( :on_ready ) EventMachine . schedule { @stats [ :total_request_count ] += 1 if @stats [ :peak_wait_response_size ] < @active_requests . size @stats [ :peak_wait_response_size ] = @active_requests . size end if ! req . oneshot @active_requests [ req . ticket ] = req end amq . queue ( endpoint_queue_name ( req . endpoint ) , { :exclusive => false , :auto_delete => true } ) @requested_endpoints [ req . endpoint ] = 1 amq . default_exchange . publish ( Serializer . instance . marshal ( req . request_hash ) , { :message_id => req . ticket , :key => endpoint_queue_name ( req . endpoint ) , :reply_to => "command-recv.#{manifest.node_id}" } ) req . process_event ( :on_sent ) } end
Publish a RPC request asynchronously.
Publish a RPC request asynchronously .
# possible timeout_sec values: # timeout_sec == -1.0 : to be overwritten to the default timeout. # timeout_sec == 0.0  : never be timed out. # timeout_sec > 0.0   : wait for the user set timeout. # set default timeout if no one updated the initial value. # create receiver queue every time before publish the message. # This helps to receive messages from the failed receiver.
req
req Request context object to be sent. If the context's state is not :init, it will fail.
req Request context object to be sent . If the context ' s state is not : init it will fail .