From d553042d1c6376dac65d263da822211fe11739c7 Mon Sep 17 00:00:00 2001 From: Ari Karim Date: Sun, 18 Jan 2026 14:30:07 +0300 Subject: [PATCH 1/2] fix: Enhance run_task method to handle existing RabbitMQ exchanges by attempting passive read before declaring new ones. --- lib/rabbit_carrots/core.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rabbit_carrots/core.rb b/lib/rabbit_carrots/core.rb index 1133fbb..a5f665f 100644 --- a/lib/rabbit_carrots/core.rb +++ b/lib/rabbit_carrots/core.rb @@ -79,7 +79,15 @@ module RabbitCarrots def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, exchange_name: nil, kill_to_restart_on_standard_error: false) RabbitCarrots::Connection.instance.channel.with do |channel| - exchange = channel.topic(exchange_name || RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true) + exchange_name ||= RabbitCarrots.configuration.rabbitmq_exchange_name + + begin + # Try to passively read an existing exchange without declaring it + exchange = channel.topic(exchange_name, passive: true) + rescue Bunny::NotFound + # If the exchange does not exist, declare it + exchange = channel.topic(exchange_name, durable: true) + end logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}" queue = channel.queue(queue_name, durable: true, arguments: queue_arguments) From 0bcaee2805572e555c70870699687158fca87412 Mon Sep 17 00:00:00 2001 From: Ari Karim Date: Sun, 18 Jan 2026 14:31:20 +0300 Subject: [PATCH 2/2] chore: Bump rabbit_carrots gem version to 1.1.1 in Gemfile.lock and version.rb. --- Gemfile.lock | 2 +- lib/rabbit_carrots/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1fac58e..7ed3643 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rabbit_carrots (1.1.0) + rabbit_carrots (1.1.1) bunny (>= 2.22) connection_pool (>= 2.4) diff --git a/lib/rabbit_carrots/version.rb b/lib/rabbit_carrots/version.rb index c02111d..163514f 100644 --- a/lib/rabbit_carrots/version.rb +++ b/lib/rabbit_carrots/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RabbitCarrots - VERSION = '1.1.0' + VERSION = '1.1.1' end