Parent

Methods

AMQP::RPC::Server

@private

Public Class Methods

new(channel, queue_name, impl) click to toggle source
# File lib/amqp/deprecated/rpc.rb, line 130
def initialize(channel, queue_name, impl)
  @channel  = channel
  @exchange = AMQP::Exchange.default(@channel)
  @queue    = @channel.queue(queue_name)
  @impl     = impl

  @handlers     = Hash.new
  @id           = "client_identifier_#{rand(1_000_000)}"

  @queue.subscribe(:ack => true) do |header, payload|
    selector, *args = Marshal.load(payload)
    result = @impl.__send__(selector, *args)

    respond_to(header, result) if header.to_hash[:reply_to]
    header.ack
  end
end

Public Instance Methods

respond_to(header, result) click to toggle source
# File lib/amqp/deprecated/rpc.rb, line 148
def respond_to(header, result)
  @exchange.publish(Marshal.dump(result), :message_id => header.message_id, :routing_key => header.reply_to)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.