Class: MessageQueue::Adapters::Bunny::Connection::Producer
- Defined in:
- lib/message_queue/adapters/bunny/producer.rb
Instance Attribute Summary collapse
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#exchange_name ⇒ Object
readonly
Returns the value of attribute exchange_name.
-
#exchange_options ⇒ Object
readonly
Returns the value of attribute exchange_options.
-
#exchange_type ⇒ Object
readonly
Returns the value of attribute exchange_type.
-
#message_options ⇒ Object
readonly
Returns the value of attribute message_options.
Attributes inherited from Producer
Instance Method Summary collapse
-
#initialize(connection, options = {}) ⇒ Producer
constructor
Public: Initialize a new Bunny producer.
- #publish(object, options = {}) ⇒ Object
Methods inherited from Producer
#default_options, #dump_object
Methods included from OptionsHelper
Constructor Details
#initialize(connection, options = {}) ⇒ Producer
Public: Initialize a new Bunny producer.
connection - The Bunny Connection. options - The Hash options used to initialize the exchange
of a producer:
:exchange -
:name - The String exchange name.
:type - The Symbol exchange type.
:durable - The Boolean exchange durability.
:message -
:routing_key - The String routing key.
:persistent - The Boolean indicate if the
persisted to disk .
Detailed see
https://github.com/ruby-amqp/bunny/blob/master/lib/bunny/exchange.rb.
Returns a Publisher.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 23 def initialize(connection, = {}) super = self..fetch(:exchange) @exchange_name = .delete(:name) || (raise "Missing exchange name") @exchange_type = .delete(:type) || (raise "Missing exchange type") = self..fetch(:message) @exchange = connection.connection.default_channel.send(exchange_type, exchange_name, ) end |
Instance Attribute Details
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
2 3 4 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 2 def exchange @exchange end |
#exchange_name ⇒ Object (readonly)
Returns the value of attribute exchange_name.
3 4 5 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 3 def exchange_name @exchange_name end |
#exchange_options ⇒ Object (readonly)
Returns the value of attribute exchange_options.
3 4 5 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 3 def end |
#exchange_type ⇒ Object (readonly)
Returns the value of attribute exchange_type.
3 4 5 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 3 def exchange_type @exchange_type end |
#message_options ⇒ Object (readonly)
Returns the value of attribute message_options.
4 5 6 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 4 def end |
Instance Method Details
#publish(object, options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/message_queue/adapters/bunny/producer.rb', line 35 def publish(object, = {}) = .merge().merge() object = dump_object(object) exchange.publish(object, ) end |