class MessageDriver::Adapters::BunnyAdapter::QueueDestination

Public Instance Methods

after_initialize(adapter_context) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 59
def after_initialize(adapter_context)
  if @dest_options[:no_declare]
    if @name.empty?
      raise MessageDriver::Error, 'server-named queues must be declared, but you provided :no_declare => true'
    end
    if @dest_options[:bindings]
      raise MessageDriver::Error, 'queues with bindings must be declared, but you provided :no_declare => true'
    end
  else
    adapter_context.with_channel(false) do |ch|
      bunny_queue(ch, init: true)
    end
  end
end
bunny_queue(channel, options = {}) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 74
def bunny_queue(channel, options = {})
  opts = @dest_options.dup
  opts[:passive] = options[:passive] if options.key? :passive
  queue = channel.queue(@name, opts)
  handle_queue_init(queue) if options.fetch(:init, false)
  queue
end
exchange_name() click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 92
def exchange_name
  ''
end
handle_consumer_count() click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 110
def handle_consumer_count
  current_adapter_context.with_channel(false) do |ch|
    bunny_queue(ch, passive: true).consumer_count
  end
end
handle_message_count() click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 100
def handle_message_count
  current_adapter_context.with_channel(false) do |ch|
    bunny_queue(ch, passive: true).message_count
  end
end
handle_queue_init(queue) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 82
def handle_queue_init(queue)
  @name = queue.name
  if (bindings = @dest_options[:bindings])
    bindings.each do |bnd|
      raise MessageDriver::Error, "binding #{bnd.inspect} must provide a source!" unless bnd[:source]
      queue.bind(bnd[:source], bnd[:args] || {})
    end
  end
end
purge() click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 116
def purge
  current_adapter_context.with_channel(false) do |ch|
    bunny_queue(ch).purge
  end
end
routing_key(_properties) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 96
def routing_key(_properties)
  @name
end
subscribe(options = {}, &consumer) click to toggle source
# File lib/message_driver/adapters/bunny_adapter.rb, line 106
def subscribe(options = {}, &consumer)
  current_adapter_context.subscribe(self, options, &consumer)
end