Commit 5076d856 authored by Phillip Webb's avatar Phillip Webb

Fix Artemis EmbeddedJMS initialization

Update `ArtemisConnectionFactoryFactory` to reference the new
embedded Artemis classes.

See gh-16646
parent 90defac7
...@@ -43,7 +43,8 @@ import org.springframework.util.StringUtils; ...@@ -43,7 +43,8 @@ import org.springframework.util.StringUtils;
*/ */
class ArtemisConnectionFactoryFactory { class ArtemisConnectionFactoryFactory {
static final String EMBEDDED_JMS_CLASS = "org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS"; static final String[] EMBEDDED_JMS_CLASSES = { "org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS",
"org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ" };
private final ArtemisProperties properties; private final ArtemisProperties properties;
...@@ -67,15 +68,17 @@ class ArtemisConnectionFactoryFactory { ...@@ -67,15 +68,17 @@ class ArtemisConnectionFactoryFactory {
} }
private void startEmbeddedJms() { private void startEmbeddedJms() {
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
try { try {
this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASS)); this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i]));
} }
catch (Exception ex) { catch (Exception ex) {
// Ignore // Ignore
} }
} }
} }
}
private <T extends ActiveMQConnectionFactory> T doCreateConnectionFactory(Class<T> factoryClass) throws Exception { private <T extends ActiveMQConnectionFactory> T doCreateConnectionFactory(Class<T> factoryClass) throws Exception {
ArtemisMode mode = this.properties.getMode(); ArtemisMode mode = this.properties.getMode();
...@@ -93,12 +96,21 @@ class ArtemisConnectionFactoryFactory { ...@@ -93,12 +96,21 @@ class ArtemisConnectionFactoryFactory {
* @return the mode * @return the mode
*/ */
private ArtemisMode deduceMode() { private ArtemisMode deduceMode() {
if (this.properties.getEmbedded().isEnabled() && ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { if (this.properties.getEmbedded().isEnabled() && isEmbeddedJmsClassPresent()) {
return ArtemisMode.EMBEDDED; return ArtemisMode.EMBEDDED;
} }
return ArtemisMode.NATIVE; return ArtemisMode.NATIVE;
} }
private boolean isEmbeddedJmsClassPresent() {
for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
return true;
}
}
return false;
}
private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(Class<T> factoryClass) private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(Class<T> factoryClass)
throws Exception { throws Exception {
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment