Add exchange_name parameter to task configuration and update exchange initialization logic

This commit is contained in:
Ari Karim 2026-01-18 09:58:11 +03:00
parent ac06deb86a
commit 4af3fe56fa
No known key found for this signature in database
GPG Key ID: 1A5559E2E32F1805

View File

@ -35,6 +35,7 @@ module RabbitCarrots
queue_name: channel[:queue],
handler_class:,
routing_keys: channel[:routing_keys],
exchange_name: channel[:exchange_name],
queue_arguments: channel[:arguments],
kill_to_restart_on_standard_error:
)
@ -78,7 +79,7 @@ module RabbitCarrots
def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, kill_to_restart_on_standard_error: false)
RabbitCarrots::Connection.instance.channel.with do |channel|
exchange = channel.topic(RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true)
exchange = channel.topic(exchange_name || RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true)
logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}"
queue = channel.queue(queue_name, durable: true, arguments: queue_arguments)