Skip to content

Commit

Permalink
ARTEMIS-2139 Fix setJMSReplyTo for 1.x clients with enable1xPrefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Nov 23, 2018
1 parent b3d700a commit d37532a
Showing 1 changed file with 31 additions and 12 deletions.
Expand Up @@ -414,25 +414,44 @@ public void setJMSReplyTo(final Destination dest) throws JMSException {
if (dest instanceof ActiveMQDestination == false) {
throw new InvalidDestinationException("Foreign destination " + dest);
}

String prefix = "";
if (dest instanceof ActiveMQTemporaryQueue) {
prefix = TEMP_QUEUE_QUALIFED_PREFIX;
} else if (dest instanceof ActiveMQQueue) {
prefix = QUEUE_QUALIFIED_PREFIX;
} else if (dest instanceof ActiveMQTemporaryTopic) {
prefix = TEMP_TOPIC_QUALIFED_PREFIX;
} else if (dest instanceof ActiveMQTopic) {
prefix = TOPIC_QUALIFIED_PREFIX;
}
ActiveMQDestination jbd = (ActiveMQDestination) dest;
final String address = jbd.getAddress();
if (enable1xPrefixes && hasPrefix1X(address)) {
MessageUtil.setJMSReplyTo(message, jbd.getAddress());
} else {
String prefix = "";
if (dest instanceof ActiveMQTemporaryQueue) {
prefix = TEMP_QUEUE_QUALIFED_PREFIX;
} else if (dest instanceof ActiveMQQueue) {
prefix = QUEUE_QUALIFIED_PREFIX;
} else if (dest instanceof ActiveMQTemporaryTopic) {
prefix = TEMP_TOPIC_QUALIFED_PREFIX;
} else if (dest instanceof ActiveMQTopic) {
prefix = TOPIC_QUALIFIED_PREFIX;
}

MessageUtil.setJMSReplyTo(message, prefix + jbd.getAddress());
MessageUtil.setJMSReplyTo(message, prefix + jbd.getAddress());
}

replyTo = jbd;
}
}

private static boolean hasPrefix1X(String address) {
if (address != null) {
if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX.toString())) {
return true;
} else if (address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX.toString())) {
return true;
} else if (address.startsWith(PacketImpl.OLD_TOPIC_PREFIX.toString())) {
return true;
} else if (address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX.toString())) {
return true;
}
}
return false;
}

@Override
public Destination getJMSDestination() throws JMSException {
if (dest == null) {
Expand Down

0 comments on commit d37532a

Please sign in to comment.