Better support for TIbco Temporary Queues/Topics

When consuming, tibco JMS client doesn’t properly identify temporary destinations with the proper type, so we must rely on the name to determine if it is temporary.
This commit is contained in:
Tyler Benson 2018-03-23 11:53:04 +08:00
parent 0d8df99f80
commit aeb1f073a3
1 changed files with 14 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import javax.jms.TemporaryTopic;
import javax.jms.Topic; import javax.jms.Topic;
public class JmsUtil { public class JmsUtil {
private static final String TIBCO_TMP_PREFIX = "$TMP$";
public static String toResourceName(final Message message, final Destination destination) { public static String toResourceName(final Message message, final Destination destination) {
Destination jmsDestination = null; Destination jmsDestination = null;
@ -18,21 +19,25 @@ public class JmsUtil {
if (jmsDestination == null) { if (jmsDestination == null) {
jmsDestination = destination; jmsDestination = destination;
} }
if (jmsDestination instanceof TemporaryQueue) {
return "Temporary Queue";
}
if (jmsDestination instanceof TemporaryTopic) {
return "Temporary Topic";
}
try { try {
if (jmsDestination instanceof Queue) { if (jmsDestination instanceof Queue) {
return "Queue " + ((Queue) jmsDestination).getQueueName(); final String queueName = ((Queue) jmsDestination).getQueueName();
if (jmsDestination instanceof TemporaryQueue || queueName.startsWith(TIBCO_TMP_PREFIX)) {
return "Temporary Queue";
} else {
return "Queue " + queueName;
}
} }
if (jmsDestination instanceof Topic) { if (jmsDestination instanceof Topic) {
return "Topic " + ((Topic) jmsDestination).getTopicName(); final String topicName = ((Topic) jmsDestination).getTopicName();
if (jmsDestination instanceof TemporaryTopic || topicName.startsWith(TIBCO_TMP_PREFIX)) {
return "Temporary Topic";
} else {
return "Topic " + topicName;
}
} }
} catch (final Exception e) { } catch (final Exception e) {
} }
return "Unknown Destination"; return "Destination";
} }
} }