class SmartQue::Publishers::Base

Public Instance Methods

channel() click to toggle source
# File lib/smart_que/publishers/base.rb, line 12
def channel
  # Raise exception if connection is not_connected or closed
  if @channel && (!@channel.open? || !@channel.connection.open?)
    raise ConnectionError
  end

  # # Create new channel if closed
  if @channel.nil? # && connection.open?
    @channel = connection.create_channel
  end
  @channel
end
config() click to toggle source
# File lib/smart_que/publishers/base.rb, line 68
def config
  ::SmartQue.config
end
connection() click to toggle source

Connection Object

# File lib/smart_que/publishers/base.rb, line 45
def connection
  ::SmartQue.establish_connection
end
find_or_initialize_queue(q_name) click to toggle source
# File lib/smart_que/publishers/base.rb, line 49
def find_or_initialize_queue(q_name)
  q = get_queue(q_name)
  q.bind(x_direct, routing_key: q.name)
end
get_queue(q_name, options = {}) click to toggle source

Get/Set queue with name name : sms_otp

# File lib/smart_que/publishers/base.rb, line 56
def get_queue(q_name, options = {})
  unless options[:dot_format] == false
    q_name = modified_q_name(q_name)
  end
  channel.queue(q_name)
end
log_message(data) click to toggle source

Logging

# File lib/smart_que/publishers/base.rb, line 64
def log_message(data)
  ::SmartQue.log(data)
end
queue_list() click to toggle source

List Queues from configuration

# File lib/smart_que/publishers/base.rb, line 8
def queue_list
  ::SmartQue.config.queues
end
x_default() click to toggle source
# File lib/smart_que/publishers/base.rb, line 30
def x_default
  channel.default_exchange
end
x_direct() click to toggle source

Direct exchange

# File lib/smart_que/publishers/base.rb, line 26
def x_direct
  channel.direct("amq.direct")
end
x_fanout() click to toggle source

Fanout exchange

# File lib/smart_que/publishers/base.rb, line 40
def x_fanout
  channel.fanout("amq.fanout")
end
x_topic() click to toggle source

Topic exchange

# File lib/smart_que/publishers/base.rb, line 35
def x_topic
  channel.topic("amq.topic")
end

Private Instance Methods

dot_formatted(name_string) click to toggle source
# File lib/smart_que/publishers/base.rb, line 78
def dot_formatted(name_string)
  name_string.downcase.gsub(/[\/|\_]/,".")
end
modified_q_name(q_name) click to toggle source
# File lib/smart_que/publishers/base.rb, line 74
def modified_q_name(q_name)
  dot_formatted(q_name)
end