class Tochtli::RabbitClient
Attributes
rabbit_connection[R]
Public Class Methods
new(rabbit_connection=nil, logger=nil)
click to toggle source
# File lib/tochtli/rabbit_client.rb, line 6 def initialize(rabbit_connection=nil, logger=nil) if rabbit_connection @rabbit_connection = rabbit_connection else @rabbit_connection = Tochtli::RabbitConnection.open(nil, logger: logger) end @logger = logger || @rabbit_connection.logger end
Public Instance Methods
publish(message, options={})
click to toggle source
# File lib/tochtli/rabbit_client.rb, line 15 def publish(message, options={}) raise InvalidMessageError.new(message.errors.join(", "), message) if message.invalid? @logger.debug "[#{Time.now} AMQP] Publishing message #{message.id} to #{message.routing_key}" reply_queue = @rabbit_connection.reply_queue options[:reply_to] = reply_queue.name if (message_handler = options[:handler]) reply_queue.register_message_handler message, message_handler, options[:timeout] end @rabbit_connection.publish message.routing_key, message, options end
reply_queue(*args)
click to toggle source
# File lib/tochtli/rabbit_client.rb, line 32 def reply_queue(*args) rabbit_connection.reply_queue(*args) end
wait_for_confirms()
click to toggle source
# File lib/tochtli/rabbit_client.rb, line 28 def wait_for_confirms @rabbit_connection.channel.wait_for_confirms end