On 02/14/2012 11:34 AM, Robbie Gemmell wrote:
The C++ client on the other hand is asking the broker via a
ExchangeBound command if there is a queue called test.topic which
happens to bound to an exchange called test.topic, and the broker is
replying that there isnt because there is no such queue. It didnt
indicate the exchange didnt exist, and thus implicitly confimed that
it did.  The client then decided to re-declare the exchange anyway
despite this, and in doing so seemed to neglect to send any exchange
type (or possibly the empty string), which the java broker interpreted
as an attempt to redeclare it with a different exchange type as it
doesnt match the existing one.

The declare sent has the passive flag set to true.

I would argue that in the spirit of that flag, it should be perfectly valid not to specify the type since we are simply asserting that it exists, not trying to create it if it does not. I couldn't find anything one way or the other in the specification however. (Attached patch to relax the check in the java broker along these lines for consideration).

One could of course also question the need to do the declare. In the case of a queue it is useful to do so as you don't get any error otherwise. Though the resolution does determine whether a queue or exchange of the specified name exists, that phase can be skipped by explicitly specifying the type. (And of course the declaration in any case does not prevent the node in question being deleted while in use).
Index: broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java
===================================================================
--- broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java	(revision 1234761)
+++ broker/src/main/java/org/apache/qpid/server/handler/ExchangeDeclareHandler.java	(working copy)
@@ -98,7 +98,7 @@
                     }
                 }
             }
-            else if (!exchange.getTypeShortString().equals(body.getType()))
+            else if (!exchange.getTypeShortString().equals(body.getType()) || ((body.getType() == null || body.getType().length() ==0) && body.getPassive()))
             {
 
                 throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " + body.getExchange() + " of type " + exchange.getTypeShortString() + " to " + body.getType() +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor(),null);

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to