Class: RubyRabbitmqJanus::Rabbit::Publisher::Admin

Inherits:
Base
  • Object
show all
Defined in:
lib/rrj/rabbit/publisher/admin.rb

Overview

This publisher send and read an message in admin queues

Author:

Instance Attribute Summary

Attributes inherited from BaseEvent

#responses

Instance Method Summary collapse

Constructor Details

#initialize(exchange) ⇒ Admin

Initialize an queue non eclusive for admin/monitor API with Janus

Parameters:

  • exchange (String)

    Exchange used for the transaction



14
15
16
17
18
# File 'lib/rrj/rabbit/publisher/admin.rb', line 14

def initialize(exchange)
  @reply = exchange.queue(Tools::Config.instance.queue_admin_from)
  super(exchange)
  subscribe_to_queue
end

Instance Method Details

#publish(request) ⇒ Janus::Response::Admin

Send an message to queue and waiting a response

Parameters:

  • request (String)

    JSON request sending to rabbitmq queue

Returns:

  • (Janus::Response::Admin)

    response for an request reading by janus instance



27
28
29
30
31
32
# File 'lib/rrj/rabbit/publisher/admin.rb', line 27

def publish(request)
  @message = request
  @exchange.publish(@message.to_json,
                    request.options.merge!(reply_to: reply.name))
  return_response
end