Class: RabbitMQ::Actors::MasterProducer
- Inherits:
-
Base::Producer
- Object
- Base::Agent
- Base::Producer
- RabbitMQ::Actors::MasterProducer
- Defined in:
- lib/rabbitmq/actors/patterns/master_workers/master_producer.rb
Overview
A producer of messages routed (via a default exchange) to a given queue. Used to distribute tasks among several worker processes listening a shared queue.
Instance Attribute Summary
Attributes inherited from Base::Agent
Instance Method Summary collapse
-
#initialize(queue_name:, **opts) ⇒ MasterProducer
constructor
A new instance of MasterProducer.
-
#publish(message, message_id:, **opts) ⇒ Object
Send a message to the RabbitMQ server.
Methods inherited from Base::Producer
Constructor Details
#initialize(queue_name:, **opts) ⇒ MasterProducer
Returns a new instance of MasterProducer.
27 28 29 |
# File 'lib/rabbitmq/actors/patterns/master_workers/master_producer.rb', line 27 def initialize(queue_name:, **opts) super(opts.merge(queue_name: queue_name, exclusive: false)) end |
Instance Method Details
#publish(message, message_id:, **opts) ⇒ Object
Send a message to the RabbitMQ server.
48 49 50 |
# File 'lib/rabbitmq/actors/patterns/master_workers/master_producer.rb', line 48 def publish(, message_id:, **opts) super(, opts.merge(message_id: , routing_key: queue.name)) end |