diff options
3 files changed, 46 insertions, 15 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java index a201f7d61e..999b22299c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java @@ -72,6 +72,17 @@ public class AMQAnyDestination extends AMQDestination implements Queue, Topic public String getTopicName() throws JMSException { - return super.getRoutingKey().toString(); + if (getRoutingKey() != null) + { + return getRoutingKey().asString(); + } + else if (getSubject() != null) + { + return getSubject(); + } + else + { + return null; + } } } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index d1e7aae94a..f85b1e655d 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -1050,7 +1050,23 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic { 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 extends BasicMessageConsumer, P extends Basic // 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) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java index c573da9def..79624a774f 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java @@ -147,13 +147,17 @@ public class AMQTopic extends AMQDestination implements Topic 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 AMQDestination implements Topic 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(); } } |