From 5076d8562ac40c16b2947e2fe6b4ec65ea293f46 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 23 Sep 2019 22:19:09 -0700 Subject: [PATCH] Fix Artemis EmbeddedJMS initialization Update `ArtemisConnectionFactoryFactory` to reference the new embedded Artemis classes. See gh-16646 --- .../ArtemisConnectionFactoryFactory.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java index 012d39bac9..fd0a76c1fa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java @@ -43,7 +43,8 @@ import org.springframework.util.StringUtils; */ 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; @@ -67,12 +68,14 @@ class ArtemisConnectionFactoryFactory { } private void startEmbeddedJms() { - if (ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { - try { - this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASS)); - } - catch (Exception ex) { - // Ignore + for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) { + if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) { + try { + this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i])); + } + catch (Exception ex) { + // Ignore + } } } } @@ -93,12 +96,21 @@ class ArtemisConnectionFactoryFactory { * @return the mode */ 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.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 createEmbeddedConnectionFactory(Class factoryClass) throws Exception { try {