qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject svn commit: r1102002 - in /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client: AMQAnyDestination.java AMQSession.java AMQTopic.java
Date Wed, 11 May 2011 18:03:37 GMT
Author: rajith
Date: Wed May 11 18:03:36 2011
New Revision: 1102002

URL: http://svn.apache.org/viewvc?rev=1102002&view=rev
Log:
QPID-3254
Added logic to resolve the address to ensure corner cases such addresses without subjects
are handled properly.
The address resolotuion code will determine the defaults for subject (and routing key) by
querying the name specified in the address.
I also added null checks for getRoutingKey() method and getTopicName() method in both AMQTopic
and AMQAnyDestination classes.

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java?rev=1102002&r1=1102001&r2=1102002&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
(original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
Wed May 11 18:03:36 2011
@@ -72,6 +72,17 @@ public class AMQAnyDestination extends A
 
     public String getTopicName() throws JMSException
     {
-        return super.getRoutingKey().toString();
+        if (getRoutingKey() != null)
+        {
+            return getRoutingKey().asString();
+        }
+        else if (getSubject() != null)
+        {
+            return getSubject();
+        }
+        else
+        {
+            return null;
+        }
     }
 }

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=1102002&r1=1102001&r2=1102002&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Wed May
11 18:03:36 2011
@@ -1050,7 +1050,23 @@ public abstract class AMQSession<C exten
     {
         checkNotClosed();
         Topic origTopic = checkValidTopic(topic, true);
+        
         AMQTopic dest = AMQTopic.createDurableTopic(origTopic, name, _connection);
+        if (dest.getDestSyntax() == DestSyntax.ADDR &&
+            !dest.isAddressResolved())
+        {
+            try
+            {
+                handleAddressBasedDestination(dest,false,true);
+            }
+            catch(AMQException e)
+            {
+                JMSException ex = new JMSException("Error when verifying destination");
+                ex.initCause(e);
+                ex.setLinkedException(e);
+                throw ex;
+            }
+        }
         
         String messageSelector = ((selector == null) || (selector.trim().length() == 0))
? null : selector;
         
@@ -1062,15 +1078,9 @@ public abstract class AMQSession<C exten
             // Not subscribed to this name in the current session
             if (subscriber == null)
             {
-                AMQShortString topicName;
-                if (topic instanceof AMQTopic)
-                {
-                    topicName = ((AMQTopic) topic).getRoutingKey();
-                } else
-                {
-                    topicName = new AMQShortString(topic.getTopicName());
-                }
-
+                // After the address is resolved routing key will not be null.
+                AMQShortString topicName = dest.getRoutingKey();
+                
                 if (_strictAMQP)
                 {
                     if (_strictAMQPFATAL)

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java?rev=1102002&r1=1102001&r2=1102002&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java Wed May
11 18:03:36 2011
@@ -147,13 +147,17 @@ public class AMQTopic extends AMQDestina
 
     public String getTopicName() throws JMSException
     {
-        if (super.getRoutingKey() == null && super.getSubject() != null)
+        if (getRoutingKey() != null)
         {
-            return super.getSubject();
+            return getRoutingKey().asString();
+        }
+        else if (getSubject() != null)
+        {
+            return getSubject();
         }
         else
         {
-            return super.getRoutingKey().toString();
+            return null;
         }
     }
     
@@ -172,12 +176,18 @@ public class AMQTopic extends AMQDestina
 
     public AMQShortString getRoutingKey()
     {
-        if (super.getRoutingKey() == null && super.getSubject() != null)
+        if (super.getRoutingKey() != null)            
+        {
+            return super.getRoutingKey();            
+        }
+        else if (getSubject() != null)
         {
-            return new AMQShortString(super.getSubject());
+            return new AMQShortString(getSubject());
         }
         else
         {
+            setRoutingKey(new AMQShortString("#"));
+            setSubject("#");
             return super.getRoutingKey();
         }
     }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message