Class: RabbitMQ::Actors::Base::Producer Abstract
- Defined in:
- lib/rabbitmq/actors/base/producer.rb
Overview
This class is abstract.
Subclass and override #pre_initialize and #exchange to define actual producer classes.
The base class to define actual RabbitMQ message producer classes.
Direct Known Subclasses
HeadersProducer, MasterProducer, Publisher, RoutingProducer, TopicProducer
Instance Attribute Summary
Attributes inherited from Agent
Instance Method Summary collapse
-
#close ⇒ Object
(also: #and_close)
Close the connection channel to RabbitMQ.
-
#publish(message, message_id:, **opts) ⇒ Object
Send a messages to RabbitMQ server.
Methods inherited from Agent
Constructor Details
This class inherits a constructor from RabbitMQ::Actors::Base::Agent
Instance Method Details
#close ⇒ Object Also known as: and_close
Close the connection channel to RabbitMQ. Log the action to the logger with info severity.
49 50 51 52 53 |
# File 'lib/rabbitmq/actors/base/producer.rb', line 49 def close logger.info(self.class.name) { "Just Before #{self} closes RabbitMQ channel!" } channel.close logger.info(self.class.name) { "Just After #{self} closes RabbitMQ channel!" } end |
#publish(message, message_id:, **opts) ⇒ Object
Send a messages to RabbitMQ server. Log the action to the logger with info severity.
36 37 38 39 40 41 42 43 |
# File 'lib/rabbitmq/actors/base/producer.rb', line 36 def publish(, message_id:, **opts) = opts.merge(message_id: ).reverse_merge!(persistent: true) .merge!(reply_to: reply_queue.name) if reply_queue logger.info(self.class.name) { "Just Before #{self} publishes message: #{} with options: #{}" } exchange.publish(, ) logger.info(self.class.name) { "Just After #{self} publishes message: #{} with options: #{}" } self end |