Skip to content

Commit 5076d85

Browse files
committed
Fix Artemis EmbeddedJMS initialization
Update `ArtemisConnectionFactoryFactory` to reference the new embedded Artemis classes. See gh-16646
1 parent 90defac commit 5076d85

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryFactory.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
*/
4444
class ArtemisConnectionFactoryFactory {
4545

46-
static final String EMBEDDED_JMS_CLASS = "org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS";
46+
static final String[] EMBEDDED_JMS_CLASSES = { "org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS",
47+
"org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ" };
4748

4849
private final ArtemisProperties properties;
4950

@@ -67,12 +68,14 @@ <T extends ActiveMQConnectionFactory> T createConnectionFactory(Class<T> factory
6768
}
6869

6970
private void startEmbeddedJms() {
70-
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) {
71-
try {
72-
this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASS));
73-
}
74-
catch (Exception ex) {
75-
// Ignore
71+
for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
72+
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
73+
try {
74+
this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i]));
75+
}
76+
catch (Exception ex) {
77+
// Ignore
78+
}
7679
}
7780
}
7881
}
@@ -93,12 +96,21 @@ private <T extends ActiveMQConnectionFactory> T doCreateConnectionFactory(Class<
9396
* @return the mode
9497
*/
9598
private ArtemisMode deduceMode() {
96-
if (this.properties.getEmbedded().isEnabled() && ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) {
99+
if (this.properties.getEmbedded().isEnabled() && isEmbeddedJmsClassPresent()) {
97100
return ArtemisMode.EMBEDDED;
98101
}
99102
return ArtemisMode.NATIVE;
100103
}
101104

105+
private boolean isEmbeddedJmsClassPresent() {
106+
for (int i = 0; i < EMBEDDED_JMS_CLASSES.length; i++) {
107+
if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
108+
return true;
109+
}
110+
}
111+
return false;
112+
}
113+
102114
private <T extends ActiveMQConnectionFactory> T createEmbeddedConnectionFactory(Class<T> factoryClass)
103115
throws Exception {
104116
try {

0 commit comments

Comments
 (0)