class RabbitMQDispatcher

Public Class Methods

new(host: @connection = Bunny.new(host: host)) click to toggle source
# File lib/postcard_rb/dispatchers/RabbitMQ/RabbitMQDispatcher.rb, line 10
def initialize host:
  @connection = Bunny.new(host: host)
  @channel = nil 
  @topics = []
end

Public Instance Methods

connect(connectionInterval:, connectionRetries: begin @connection.start) click to toggle source
# File lib/postcard_rb/dispatchers/RabbitMQ/RabbitMQDispatcher.rb, line 21
def connect connectionInterval:, connectionRetries: 
  begin  
    @connection.start

    createChannel()
  rescue Bunny::TCPConnectionFailedForAllHosts
    sleep connectionInterval
    connectionRetries -= 1

    raise DispatcherConnectionRefused if connectionRetries == 0

    connect(
      connectionInterval: connectionInterval, 
      connectionRetries: connectionRetries
    )
  end
createChannel() click to toggle source
# File lib/postcard_rb/dispatchers/RabbitMQ/RabbitMQDispatcher.rb, line 16
def createChannel
  @channel = @connection.create_channel
  @channel.prefetch(1)
end