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.
This commit is contained in:
Martyn Taylor 2018-02-01 15:52:25 +00:00 committed by Justin Bertram
parent 8bb7ad2dda
commit 8f47cd6e14
2 changed files with 34 additions and 0 deletions

View File

@ -542,6 +542,11 @@ public class ActiveMQActivation {
}
String calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1);
if (isTopic && spec.getTopicPrefix() != null) {
calculatedDestinationName = spec.getTopicPrefix() + calculatedDestinationName;
} else if (!isTopic && spec.getQueuePrefix() != null) {
calculatedDestinationName = spec.getQueuePrefix() + calculatedDestinationName;
}
logger.debug("Unable to retrieve " + destinationName +
" from JNDI. Creating a new " + destinationType.getName() +

View File

@ -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 class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen
}
}
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 class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen
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 class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen
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;
}
}