Sha256: 7291bd0fb35757c795b95dc49da91fc6016f6adf3b90bf6e96086267d3bc8b19

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

module FDE
  module Rabbit
    class Message
      attr_accessor :conneciton,
        :channel,
        :exchange,
        :name,
        :payload

      def initialize(payload, exchange_name)
        @payload = payload
        @name = exchange_name
      end

      def deliver(key)
        start
        exchange.publish(payload, routing_key: key)
      end

      def connection
        @connection ||= Connection.new
      end

      def channel
        @channel ||= connection.create_channel
      end

      def exchange
        @exchange ||= Bunny::Exchange.new(
          channel, :topic, @name, durable: true
        )
      end

      def start
        connection.start
      end

      def close
        connection.close
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fde-rabbit-notification-0.5.0 lib/rabbit/message.rb
fde-rabbit-notification-0.4.1 lib/rabbit/message.rb
fde-rabbit-notification-0.4.0 lib/rabbit/message.rb
fde-rabbit-notification-0.3.0 lib/rabbit/message.rb