Bug 621395 - Cannot create a durable subscription using a destination created with an addressing string
Cannot create a durable subscription using a destination created with an addr...
Status: CLOSED ERRATA
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-java (Show other bugs)
Development
All Linux
high Severity high
: 1.3
: ---
Assigned To: Rajith Attapattu
Jeff Needle
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-04 18:39 EDT by Rajith Attapattu
Modified: 2014-06-23 10:31 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-10-20 07:29:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rajith Attapattu 2010-08-04 18:39:01 EDT
Description of problem:
If you pass in a topic created using an addressing string, to createDurableSubscriber method, the JMS client throws an exception complaining that the exchange and routing key fields are null.
The code needs to take into account the destination syntax and retrieve the appropriate information.

Version-Release number of selected component (if applicable):
All previous versions

How reproducible:
Always

Steps to Reproduce:
1. Try to create durable subscriber with a topic (amq.topic/news.us).
   Ex MessageConsumer cons = ssn.createDurableSubscriber(ssn.createTopic("amq.topic/news.us"), "my-sub");

2. Observe the exception being thrown saying exchange name is null.
  
Actual results:
Exception thrown saying exchange name is null.

Expected results:
Should succeed without any issue.
Comment 1 Rajith Attapattu 2010-08-05 11:06:25 EDT
The following patch contains the initial fix.

--- 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 Aug  4 19:44:17 2010
@@ -106,8 +106,20 @@ public class AMQTopic extends AMQDestina
    public static AMQTopic createDurable010Topic(AMQTopic topic, String subscriptionName, AMQConnection connection)
            throws JMSException
    {
-        return new AMQTopic(topic.getExchangeName(), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topic.getRoutingKey(), true, false,
+        if (topic.getDestSyntax() == AMQDestination.DestSyntax.BURL)
+        {
+            return new AMQTopic(topic.getExchangeName(), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topic.getRoutingKey(), true, false,
              getDurableTopicQueueName(subscriptionName, connection), true);
+        }
+        else
+        {
+            return new AMQTopic(new AMQShortString(topic.getAddressName()),
+                                ExchangeDefaults.TOPIC_EXCHANGE_CLASS,
+                                new AMQShortString(topic.getSubject()),
+                                true,
+                                false,
+                                getDurableTopicQueueName(subscriptionName, connection), true);
+        }
    }

    public static AMQShortString getDurableTopicQueueName(String subscriptionName, AMQConnection connection) throws JMSException
Comment 2 Rajith Attapattu 2010-08-05 11:08:36 EDT
The patch below reverts the above commit and adds a more simple fix to avoid checking dest style in createDurable010Topic, hashcode and equals methods.

--- 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 Thu Aug  5 15:03:40 2010
@@ -106,20 +106,8 @@ public class AMQTopic extends AMQDestina
    public static AMQTopic createDurable010Topic(AMQTopic topic, String subscriptionName, AMQConnection connection)
            throws JMSException
    {
-        if (topic.getDestSyntax() == AMQDestination.DestSyntax.BURL)
-        {
-            return new AMQTopic(topic.getExchangeName(), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topic.getRoutingKey(), true, false,
-              getDurableTopicQueueName(subscriptionName, connection), true);
-        }
-        else
-        {
-            return new AMQTopic(new AMQShortString(topic.getAddressName()),
-                                ExchangeDefaults.TOPIC_EXCHANGE_CLASS,
-                                new AMQShortString(topic.getSubject()),
-                                true,
-                                false,
-                                getDurableTopicQueueName(subscriptionName, connection), true);
-        }
+        return new AMQTopic(topic.getExchangeName(), ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topic.getRoutingKey(), true, false,
+                getDurableTopicQueueName(subscriptionName, connection), true);
    }

    public static AMQShortString getDurableTopicQueueName(String subscriptionName, AMQConnection connection) throws JMSException
@@ -129,12 +117,39 @@ public class AMQTopic extends AMQDestina

    public String getTopicName() throws JMSException
    {
-        return super.getRoutingKey().toString();
+        if (super.getRoutingKey() == null && super.getSubject() != null)
+        {
+            return super.getSubject();
+        }
+        else
+        {
+            return super.getRoutingKey().toString();
+        }
+    }
+
+    @Override
+    public AMQShortString getExchangeName()
+    {
+        if (super.getExchangeName() == null && super.getAddressName() != null)
+        {
+            return new AMQShortString(super.getAddressName());
+        }
+        else
+        {
+            return _exchangeName;
+        }
    }

    public AMQShortString getRoutingKey()
    {
-        return super.getRoutingKey();
+        if (super.getRoutingKey() == null && super.getSubject() != null)
+        {
+            return new AMQShortString(super.getSubject());
+        }
+        else
+        {
+            return super.getRoutingKey();
+        }
    }
Comment 3 Rajith Attapattu 2010-08-12 15:22:29 EDT
The following shows the exact code segment that will get changed.
In summary,

If the exchange name is null, and address name name is not null, it will return the address name.

If the routing key is null, and subject is not null, it will return the subject.


@@ -129,12 +117,39 @@ public class AMQTopic extends AMQDestina

    public String getTopicName() throws JMSException
    {
-        return super.getRoutingKey().toString();
+        if (super.getRoutingKey() == null && super.getSubject() != null)
+        {
+            return super.getSubject();
+        }
+        else
+        {
+            return super.getRoutingKey().toString();
+        }
+    }
+
+    @Override
+    public AMQShortString getExchangeName()
+    {
+        if (super.getExchangeName() == null && super.getAddressName() != null)
+        {
+            return new AMQShortString(super.getAddressName());
+        }
+        else
+        {
+            return _exchangeName;
+        }
    }

    public AMQShortString getRoutingKey()
    {
-        return super.getRoutingKey();
+        if (super.getRoutingKey() == null && super.getSubject() != null)
+        {
+            return new AMQShortString(super.getSubject());
+        }
+        else
+        {
+            return super.getRoutingKey();
+        }
    }
Comment 4 Rajith Attapattu 2010-08-31 18:10:39 EDT
This is tracked in upstream via QPID-2786 and fixed in rev 982652 in Qpid trunk.
I have ported the fix to the internal git repo under the following commit.

http://mrg1.lab.bos.redhat.com/cgit/qpid.git/commit/?id=e6f1a55eff9c7e4552aa49a9058ba9d43393f334
Comment 5 Jiri Kolar 2010-09-06 09:35:12 EDT
this appear on 1.2 and
is fixed on qpid-java-client-0.7.946106-8
validated on RHEL5.5/RHEL4  i386 / x86_64  

packages:

# rpm -qa | grep -E '(qpid|openais|rhm)' | sort -u
openais-0.80.6-16.el5_5.7
openais-devel-0.80.6-16.el5_5.7
python-qpid-0.7.946106-12.el5
qpid-cpp-client-0.7.946106-12.el5
qpid-cpp-client-devel-0.7.946106-12.el5
qpid-cpp-client-devel-docs-0.7.946106-12.el5
qpid-cpp-client-ssl-0.7.946106-12.el5
qpid-cpp-mrg-debuginfo-0.7.946106-11.el5
qpid-cpp-server-0.7.946106-12.el5
qpid-cpp-server-cluster-0.7.946106-12.el5
qpid-cpp-server-devel-0.7.946106-12.el5
qpid-cpp-server-ssl-0.7.946106-12.el5
qpid-cpp-server-store-0.7.946106-12.el5
qpid-cpp-server-xml-0.7.946106-12.el5
qpid-java-client-0.7.946106-8.el5
qpid-java-common-0.7.946106-8.el5
qpid-tools-0.7.946106-8.el5
rhm-docs-0.7.946106-4.el5
rh-tests-distribution-MRG-Messaging-qpid_common-1.6-53


->VERIFIED

Note You need to log in before you can comment on or make changes to this bug.