Class: Ears::PublisherConfirmationHandler
- Inherits:
-
Object
- Object
- Ears::PublisherConfirmationHandler
- Defined in:
- lib/ears/publisher_confirmation_handler.rb
Overview
Handles publisher confirmations for RabbitMQ messages.
This class encapsulates the logic for publishing messages with confirmations, including timeout handling, channel cleanup, and pool coordination.
Instance Method Summary collapse
-
#initialize(config:, logger:) ⇒ PublisherConfirmationHandler
constructor
Creates a new confirmation handler.
-
#publish_with_confirmation(channel:, exchange:, data:, routing_key:, options:) ⇒ void
Publishes a message with confirmation.
Constructor Details
#initialize(config:, logger:) ⇒ PublisherConfirmationHandler
Creates a new confirmation handler.
13 14 15 16 |
# File 'lib/ears/publisher_confirmation_handler.rb', line 13 def initialize(config:, logger:) @config = config @logger = logger end |
Instance Method Details
#publish_with_confirmation(channel:, exchange:, data:, routing_key:, options:) ⇒ void
This method returns an undefined value.
Publishes a message with confirmation.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ears/publisher_confirmation_handler.rb', line 29 def publish_with_confirmation( channel:, exchange:, data:, routing_key:, options: ) exchange.publish(data, { routing_key: routing_key }.merge()) timeout = config.publisher_confirms_timeout unless wait_for_confirms_with_timeout(channel, timeout) handle_confirmation_failure(channel, timeout) end end |