class Cony::AMQPConnectionHandler
Public Class Methods
new(config)
click to toggle source
# File lib/cony/amqp_connection_handler.rb, line 6 def initialize(config) @config = config end
Public Instance Methods
publish(message, routing_key)
click to toggle source
# File lib/cony/amqp_connection_handler.rb, line 10 def publish(message, routing_key) Bunny.run(@config) do |connection| channel = connection.create_channel exchange = channel.topic(@config[:exchange], durable: Cony.config.durable) exchange.publish(message.to_json, key: routing_key, mandatory: false, immediate: false, persistent: Cony.config.durable, content_type: 'application/json') end rescue => error Raven.capture_exception(error) if defined?(Raven) Rails.logger.error("#{error.class}: #{error}") if defined?(Rails) end