From 041373b04ee52c224059edfd1b4bcc54e448e360 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Thu, 1 Feb 2018 15:52:25 +0000 Subject: [PATCH] ARTEMIS-1658 Add prefix option to ActivationSpec Artemis 1.x RA would do a core queue lookup if it could not find the Destination in JNDI. We need to ensure that we can support the old address model for backwards compatability. --- .../artemis/ra/inflow/ActiveMQActivation.java | 9 +++++- .../ra/inflow/ActiveMQActivationSpec.java | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java index 97498a26790..b814fc8c3f7 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java @@ -541,7 +541,14 @@ protected void setupDestination() throws Exception { throw ActiveMQRABundle.BUNDLE.noDestinationName(); } - String calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1); + String calculatedDestinationName; + if (isTopic && spec.getTopicPrefix() != null) { + calculatedDestinationName = spec.getTopicPrefix() + destinationName.substring(destinationName.lastIndexOf('/') + 1); + } else if (!isTopic && spec.getQueuePrefix() != null) { + calculatedDestinationName = spec.getQueuePrefix() + destinationName.substring(destinationName.lastIndexOf('/') + 1); + } else { + calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1); + } logger.debug("Unable to retrieve " + destinationName + " from JNDI. Creating a new " + destinationType.getName() + diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java index fed36db895f..d46b2a79d7d 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java @@ -53,6 +53,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen public String strConnectionParameters; protected Boolean allowLocalTransactions; + /** * The resource adapter */ @@ -135,6 +136,11 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen private Boolean rebalanceConnections = false; + // Enables backwards compatibility of the pre 2.x addressing model + private String topicPrefix; + + private String queuePrefix; + /** * Constructor */ @@ -368,6 +374,23 @@ public String getAcknowledgeMode() { } } + + public void setQueuePrefix(String prefix) { + this.queuePrefix = prefix; + } + + public String getQueuePrefix() { + return queuePrefix; + } + + public void setTopicPrefix(String prefix) { + this.topicPrefix = prefix; + } + + public String getTopicPrefix() { + return topicPrefix; + } + /** * Set the acknowledge mode * @@ -878,6 +901,10 @@ public boolean equals(Object o) { return false; if (setupAttempts != null ? !setupAttempts.equals(that.setupAttempts) : that.setupAttempts != null) return false; + if (queuePrefix != null ? !queuePrefix.equals(that.queuePrefix) : that.queuePrefix != null) + return false; + if (topicPrefix != null ? !topicPrefix.equals(that.topicPrefix) : that.topicPrefix != null) + return false; return !(setupInterval != null ? !setupInterval.equals(that.setupInterval) : that.setupInterval != null); } @@ -907,6 +934,8 @@ public int hashCode() { result = 31 * result + (rebalanceConnections != null ? rebalanceConnections.hashCode() : 0); result = 31 * result + (setupAttempts != null ? setupAttempts.hashCode() : 0); result = 31 * result + (setupInterval != null ? setupInterval.hashCode() : 0); + result = 31 * result + (queuePrefix != null ? queuePrefix.hashCode() : 0); + result = 31 * result + (topicPrefix != null ? queuePrefix.hashCode() :0); return result; } }