Class: RubyRabbitmqJanus::Rabbit::Publisher::BasePublisher Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rrj/rabbit/publish/base_publisher.rb

Overview

This class is abstract.

Publish message in RabbitMQ

# Parent class for all publisher This element send and read a message in rabbitmq Queue

Direct Known Subclasses

Listener, Publisher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBasePublisher

Define a base publisher



23
24
25
26
27
28
29
# File 'lib/rrj/rabbit/publish/base_publisher.rb', line 23

def initialize
  @responses = []
  @semaphore = Semaphore.new
  @lock = Mutex.new
rescue
  raise Errors::Rabbit::BasePublisher::Initialize
end

Instance Attribute Details

#responseRubyRabbitmqJanus::Janus::Responses::Response (readonly)

Returns Given a Janus response.

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rrj/rabbit/publish/base_publisher.rb', line 19

class BasePublisher
  attr_reader :responses

  # Define a base publisher
  def initialize
    @responses = []
    @semaphore = Semaphore.new
    @lock = Mutex.new
  rescue
    raise Errors::Rabbit::BasePublisher::Initialize
  end

  private

  attr_accessor :semaphore, :lock

  def return_response
    @semaphore.wait
    response = nil
    @lock.synchronize do
      response = @responses.shift
    end
    response
  end
end

#responsesObject (readonly)

Returns the value of attribute responses.



20
21
22
# File 'lib/rrj/rabbit/publish/base_publisher.rb', line 20

def responses
  @responses
end