Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Commit

Permalink
If :passive option is given, don't raise IncompatibleOptionsError eve…
Browse files Browse the repository at this point in the history
…n when options do not match
  • Loading branch information
michaelklishin committed Jan 18, 2011
1 parent 3db0f75 commit 940e76b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/mq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def closed?
def direct(name = 'amq.direct', opts = {}, &block)
if exchange = self.exchanges.find { |exchange| exchange.name == name }
extended_opts = Exchange.add_default_options(:direct, name, opts, block)
if exchange.opts == extended_opts
if exchange.opts == extended_opts || extended_opts[:passive]
return exchange
else
raise IncompatibleOptionsError.new(name, exchange.opts, extended_opts)
Expand Down
6 changes: 0 additions & 6 deletions lib/mq/exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,6 @@ def auto_deleted?
end # auto_deleted?
alias auto_deletable? auto_deleted?

# Signifies that exchange object was created with :passive parameter set to true and
# thus should not really be used for publishing.
def passive?
!!@opts[:passive]
end # passive?


def reset
@deferred_status = nil
Expand Down
10 changes: 3 additions & 7 deletions spec/mq/exchange_declaration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,12 @@
context "when passive option is used" do
context "and exchange with given name already exists" do
it "silently returns" do
pending "Incompatible options exception kicks in. We need to handle :passive option better."
name = "a_new_direct_exchange declared at #{Time.now.to_i}"

@channel.direct(name)
exchange = @channel.direct(name, :passive => true)
original_exchange = @channel.direct(name)
exchange = @channel.direct(name, :passive => true)

exchange.name.should == name
# this predicate signifies that this object should not be used
# for publishing
exchange.should be_passive
exchange.should == original_exchange

done
end # it
Expand Down

0 comments on commit 940e76b

Please sign in to comment.