class Rabbitek::Utils::Common

Common utilities to create/use RabbitMQ exchange or queue

Public Class Methods

exchange(channel, exchange_type, exchange_name) click to toggle source
# File lib/rabbitek/utils/common.rb, line 9
def exchange(channel, exchange_type, exchange_name)
  channel.public_send(exchange_type || 'direct', exchange_name, durable: true, auto_delete: false)
end
queue(channel, name, opts) click to toggle source
# File lib/rabbitek/utils/common.rb, line 13
def queue(channel, name, opts)
  opts ||= {}
  opts = symbolize_keys(opts.to_hash)
  opts[:durable] = true
  opts[:auto_delete] = false

  channel.queue(name, opts)
end

Private Class Methods

symbolize_keys(hash) click to toggle source
# File lib/rabbitek/utils/common.rb, line 24
def symbolize_keys(hash)
  hash.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
end