Sha256: 0208b00c8e06f159b51ffcad755862dbf3480822508196ec5f2530f3640d91e3
Contents?: true
Size: 810 Bytes
Versions: 2
Compression:
Stored size: 810 Bytes
Contents
require 'bunny' require 'json' module Cony class AMQPConnectionHandler def initialize(config) @config = config end 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 Airbrake.notify_or_ignore(error) if defined?(Airbrake) Rails.logger.error("#{error.class}: #{error}") if defined?(Rails) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cony-2.0.0 | lib/cony/amqp_connection_handler.rb |
cony-1.5.0 | lib/cony/amqp_connection_handler.rb |