Sha256: b056b29599f608b81f33996201d3fa3e81e55b34552327115648ba6a1e8739eb

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

require 'bunny'
module Splash
  module Transports
    module RabbitMQ

      class Subscriber
        def initialize

        end
      end


      class Client
        def initialize
          @connection = Bunny.new
          @connection.start
          @channel = @connection.create_channel
        end


        def publish(options ={})
          return @channel.default_exchange.publish(options[:message], :routing_key => options[:queue])
        end

        def ack
          return @channel.acknowledge(delivery_info.delivery_tag, false)
        end


        def get(options ={})
          queue = @channel.queue(options[:queue])
          delivery_info, properties, payload = queue.pop
          res = {:message => payload}
          res[:ack] = delivery_info.delivery_tag if options[:noack]
          return res
        end

        def close
          @connection.close
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-splash-0.0.3 lib/splash/transports/rabbitmq.rb