Sha256: c822aa6f10d2a40e88c1e6b9da36dd4ec2c4484c0e7c0cb80e415bb30bdb3331
Contents?: true
Size: 799 Bytes
Versions: 19
Compression:
Stored size: 799 Bytes
Contents
require 'bunny' require 'yajl' class AmqpQueueDecorator def initialize queue @queue = queue end def pop m = @queue.pop p = m[:payload] p == :queue_empty ? nil : p end end class AmqpExchangeDecorator def initialize exchange @exchange = exchange end def publish msg serialized_msg = Yajl::Encoder.encode(msg) @exchange.publish serialized_msg end end class AmqpService def initialize connection_config @connection_config = connection_config.merge(:spec => "09") end def start_worker file_queue_name, reply_exchange_name Bunny.run @connection_config do |b| queue = b.queue file_queue_name exchange = b.exchange reply_exchange_name yield AmqpQueueDecorator.new(queue), AmqpExchangeDecorator.new(exchange) end end end
Version data entries
19 entries across 19 versions & 1 rubygems