lib/pwwka/channel_connector.rb in pwwka-0.14.0 vs lib/pwwka/channel_connector.rb in pwwka-0.15.0
- old
+ new
@@ -6,16 +6,19 @@
attr_reader :channel
# The channel_connector starts the connection to the message_bus
# so it should only be instantiated by a method that has a strategy
# for closing the connection
- def initialize
+ def initialize(prefetch: nil)
@configuration = Pwwka.configuration
connection_options = {automatically_recover: false}.merge(configuration.options)
@connection = Bunny.new(configuration.rabbit_mq_host,
connection_options)
@connection.start
@channel = @connection.create_channel
+ if prefetch
+ @channel.prefetch(prefetch.to_i)
+ end
end
def topic_exchange
@topic_exchange ||= channel.topic(configuration.topic_exchange_name, durable: true)
end