### Home Classes Methods

### In Files

- lib/amqp/deprecated/rpc.rb

### Parent

Object

### Methods

- ::new
- #method_missing

### 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::Client

@private

### Attributes

identifier[RW]

### Public Class Methods

new(channel, server_queue_name) click to toggle source

    # File lib/amqp/deprecated/rpc.rb, line 98
    def initialize(channel, server_queue_name)
      @channel           = channel
      @exchange          = AMQP::Exchange.default(@channel)
      @server_queue_name = server_queue_name

      @handlers          = Hash.new
      @queue             = channel.queue("__amqp_gem_rpc_client_#{rand(1_000_000)}", :auto_delete => true)

      @queue.subscribe do |header, payload|
        *response_args = Marshal.load(payload)
        handler        = @handlers[header.message_id]

        handler.call(*response_args)
      end
    end

### Public Instance Methods

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

    # File lib/amqp/deprecated/rpc.rb, line 114
    def method_missing(selector, *args, &block)
      @channel.once_open do
        message_id   = "message_identifier_#{rand(1_000_000)}"

        if block
          @handlers[message_id] = block
          @exchange.publish(Marshal.dump([selector, *args]), :routing_key => @server_queue_name, :reply_to => @queue.name, :message_id => message_id)
        else
          @exchange.publish(Marshal.dump([selector, *args]), :routing_key => @server_queue_name, :message_id => message_id)
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.