### Home Classes Methods

### In Files

- lib/amqp/deprecated/rpc.rb

### Parent

AMQP::BlankSlate

### Namespace

- CLASS AMQP::RPC::Client
- CLASS AMQP::RPC::Server

### Methods

- ::new
- #client?
- #method_missing
- #normalize
- #server?

### Class/Module Index

Quicksearch

- AMQP
- AMQP::BitSet
- AMQP::BlankSlate
- AMQP::Broker
- AMQP::Channel
- AMQP::ChannelClosedError
- AMQP::Client
- AMQP::Consumer
- AMQP::Error
- AMQP::Exchange
- AMQP::Header
- AMQP::IncompatibleOptionsError
- AMQP::IntAllocator
- AMQP::Integration
- AMQP::Integration::Rails
- AMQP::Logger
- AMQP::PossibleAuthenticationFailureError
- AMQP::Queue
- AMQP::RPC
- AMQP::RPC::Client
- AMQP::RPC::Server
- AMQP::Session
- AMQP::TCPConnectionFailed
- AMQP::Utilities
- AMQP::Utilities::EventLoopHelper
- AMQP::Utilities::ServerType
- MQ
- MQ::Exchange
- MQ::Logger
- MQ::Queue
- EM
- Object

No matching classes.

# AMQP::RPC

Basic RPC (remote procedure call) facility.

Needs more detail and explanation.

    EM.run do
      server = AMQP::Channel.new.rpc('hash table node', Hash)

      client = AMQP::Channel.new.rpc('hash table node')
      client[:now] = Time.now
      client[:one] = 1

      client.values do |res|
        p 'client', :values => res
      end

      client.keys do |res|
        p 'client', :keys => res
        EM.stop_event_loop
      end
    end

@note This class will be removed before 1.0 release. @deprecated @private

### Attributes

name[R]

API

### Public Class Methods

new(channel, queue, obj = nil) click to toggle source

Takes a channel, queue and optional object.

The optional object may be a class name, module name or object instance. When given a class or module name, the object is instantiated during this setup. The passed queue is automatically subscribed to so it passes all messages (and their arguments) to the object.

Marshalling and unmarshalling the objects is handled internally. This marshalling is subject to the same restrictions as defined in the {ruby-doc.org/core/classes/Marshal.html Marshal} standard library. See that documentation for further reference.

When the optional object is not passed, the returned rpc reference is used to send messages and arguments to the queue. See method_missing which does all of the heavy lifting with the proxy. Some client elsewhere must call this method with the optional block so that there is a valid destination. Failure to do so will just enqueue marshalled messages that are never consumed.

    # File lib/amqp/deprecated/rpc.rb, line 67
    def initialize(channel, queue, obj = nil)
      @name    = queue
      @channel = channel
      @channel.register_rpc(self)

      if @obj = normalize(obj)
        @delegate = Server.new(channel, queue, @obj)
      else
        @delegate = Client.new(channel, queue)
      end
    end

### Public Instance Methods

client?() click to toggle source

    # File lib/amqp/deprecated/rpc.rb, line 80
    def client?
      @obj.nil?
    end

method_missing(selector, *args, &block) click to toggle source

    # File lib/amqp/deprecated/rpc.rb, line 89
    def method_missing(selector, *args, &block)
      @delegate.__send__(selector, *args, &block)
    end

server?() click to toggle source

    # File lib/amqp/deprecated/rpc.rb, line 84
    def server?
      !client?
    end

### Protected Instance Methods

normalize(input) click to toggle source

    # File lib/amqp/deprecated/rpc.rb, line 157
    def normalize(input)
      case input
      when ::Class
        input.new
      when ::Module
        (::Class.new do include(obj) end).new
      else
        input
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.