Skip to content

Commit d376913

Browse files
Closes #661
1 parent d5bfb6d commit d376913

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/bunny/channel.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def headers(name, opts = {})
378378
# @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
379379
# @api public
380380
def default_exchange
381-
Exchange.default(self)
381+
@default_exchange ||= Exchange.default(self)
382382
end
383383

384384
# Declares a headers exchange or looks it up in the cache of previously
@@ -396,7 +396,7 @@ def default_exchange
396396
# @see http://rubybunny.info/articles/exchanges.html Exchanges and Publishing guide
397397
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions to AMQP 0.9.1 guide
398398
def exchange(name, opts = {})
399-
Exchange.new(self, opts.fetch(:type, :direct), name, opts)
399+
find_exchange(name) || Exchange.new(self, opts.fetch(:type, :direct), name, opts)
400400
end
401401

402402
# @endgroup

0 commit comments

Comments
 (0)