Class: RubyRabbitmqJanus::Rabbit::Publisher::PublishExclusive

Inherits:
RubyRabbitmqJanus::Rabbit::Publisher show all
Defined in:
lib/rrj/rabbit/publish/exclusive.rb

Overview

# Publish message

Publish message in queue exclusive. Bunny create automaticaly a name for this queue. The queue name like to ‘amq.gen-1A456DGVHDVUS’.

Author:

Instance Method Summary collapse

Constructor Details

#initialize(exchange, name_queue) ⇒ PublishExclusive

Initialize an queue exclusive and generated automaticaly by bunny

Parameters:

  • exchange (String)

    Exchange used for the transaction

  • name_queue (String)

    Name to queue exclusive



17
18
19
20
21
22
23
# File 'lib/rrj/rabbit/publish/exclusive.rb', line 17

def initialize(exchange, name_queue)
  @reply = exchange.queue(name_queue, exclusive: true)
  super(exchange)
  subscribe_to_queue
rescue
  raise Errors::Rabbit::PublishExclusive::Initialize
end

Instance Method Details

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

Send an message to queue and waiting a response

Parameters:

  • request (String)

    JSON request sending to rabbitmq queue

Returns:

  • (Janus::Response::Standard)

    response for an request reading by janus instance



31
32
33
34
35
36
# File 'lib/rrj/rabbit/publish/exclusive.rb', line 31

def publish(request)
  super(request)
  return_response
rescue
  raise Errors::Rabbit::PublishExclusive::Publish
end