class BaseRabbitMQRoom

Public Class Methods

new(channel:, queue:, exclusive: false) click to toggle source
# File lib/postcard_rb/dispatchers/RabbitMQ/routings/BaseRabbitMQRoom.rb, line 4
def initialize channel:, queue:, exclusive: false
  @channel = channel
  @queue = queue
  @exclusive = exclusive
end

Public Instance Methods

subscribe(block: true) { |delivery_info, properties, payload| ... } click to toggle source
# File lib/postcard_rb/dispatchers/RabbitMQ/routings/BaseRabbitMQRoom.rb, line 10
def subscribe block: true
  begin
    manual_ack = false

    manual_ack = true if @exclusive

    @queue.subscribe(manual_ack: manual_ack, block: block) do |delivery_info, properties, payload|
      yield delivery_info, properties, payload

      @channel.ack(delivery_info.delivery_tag) if @exclusive
    end
  rescue Interrupt => _
  
  end
end