Sha256: ea0d90a990fdb856ce811d3a12625bb7ba359cde47e8f69013ba59dc3dc8bfa2
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
class MessageQueue::Adapters::Bunny::Connection::Publisher attr_reader :connection, :exchange attr_reader :exchange_options, :exchange_name, :exchange_type attr_reader :message_options # Public: Initialize a new Bunny publisher. # # connection - The Bunny Connection. # options - The Hash options used to initialize the exchange # of a publisher: # :exchange - # :name - The String exchange name. # :type - The Symbol exchange type. # :durable - The Boolean exchange durability. # :message - # :routing_key - The String message routing key. # :persistent - The Boolean indicate if the # message persisted to disk . # Detailed options see # https://github.com/ruby-amqp/bunny/blob/master/lib/bunny/exchange.rb. # # Returns a Publisher. def initialize(connection, options = {}) @connection = connection options = options.dup @exchange_options = options.fetch(:exchange) @exchange_name = exchange_options.delete(:name) || (raise "Missing exchange name") @exchange_type = exchange_options.delete(:type) || (raise "Missing exchange type") @message_options = options.fetch(:message) @exchange = connection.connection.default_channel.send(exchange_type, exchange_name, exchange_options) end def publish(payload, options = {}) exchange.publish(connection.serializer.dump(payload), message_options.merge(options)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
message_queue-0.0.3 | lib/message_queue/adapters/bunny/publisher.rb |
message_queue-0.0.2 | lib/message_queue/adapters/bunny/publisher.rb |