Sha256: b41f073bf8514c3ccb793a36f95c009ce6845fca93115b93063729d1ffcbaaee

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

require 'bunny'

class Logasm
  module Adapters
    class RabbitmqAdapter
      class Publisher
        def initialize(queue, config)
          connection = Bunny.new("amqp://#{config[:user]}:#{config[:pass]}@#{config[:host]}:#{config[:port]}")
          connection.start
          @exchange = connection.create_channel.default_exchange
          @queue = queue
        end

        def publish(message)
          @exchange.publish(message.to_json, :routing_key => @queue)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logasm-0.2.0 lib/logasm/adapters/rabbitmq_adapter/publisher.rb