From df2074720d9563678d1cbfa678f9f93a5f80af14 Mon Sep 17 00:00:00 2001 From: Dmitry Zenovich Date: Tue, 26 Apr 2016 02:52:01 +0300 Subject: [PATCH] add exchange_options to 'with_exchange' and 'publish' methods --- lib/active_publisher.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/active_publisher.rb b/lib/active_publisher.rb index e7c9dc4..e90e416 100644 --- a/lib/active_publisher.rb +++ b/lib/active_publisher.rb @@ -27,8 +27,8 @@ def self.configure # @param [String] payload The message you are sending. Should already be encoded as a string. # @param [String] exchange The exchange you want to publish to. # @param [Hash] options hash to set message parameters (e.g. headers) - def self.publish(route, payload, exchange_name, options = {}) - with_exchange(exchange_name) do |exchange| + def self.publish(route, payload, exchange_name, options = {}, exchange_options = {}) + with_exchange(exchange_name, exchange_options) do |exchange| exchange.publish(payload, publishing_options(route, options)) end end @@ -49,12 +49,12 @@ def self.publishing_options(route, options = {}) end end - def self.with_exchange(exchange_name) + def self.with_exchange(exchange_name, exchange_options = {}) connection = ::ActivePublisher::Connection.connection channel = connection.create_channel begin channel.confirm_select if configuration.publisher_confirms - exchange = channel.topic(exchange_name) + exchange = channel.topic(exchange_name, exchange_options) yield(exchange) channel.wait_for_confirms if configuration.publisher_confirms ensure