Sha256: 3806526de2e8a1d0292eb9bb4184cf4485f971a299561d90ac11e2cb256623fe

Contents?: true

Size: 633 Bytes

Versions: 3

Compression:

Stored size: 633 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|
        exchange = connection.exchange(@config[:exchange], type: :topic, 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
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cony-1.1.0 lib/cony/amqp_connection_handler.rb
cony-1.0.1 lib/cony/amqp_connection_handler.rb
cony-1.0.0 lib/cony/amqp_connection_handler.rb