Fix Artemis EmbeddedJMS initialization

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

See gh-16646
pull/18337/head
Phillip Webb 5 years ago
parent 90defac71c
commit 5076d8562a

@ -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,12 +68,14 @@ 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++) {
try { if (ClassUtils.isPresent(EMBEDDED_JMS_CLASSES[i], null)) {
this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASS)); try {
} this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASSES[i]));
catch (Exception ex) { }
// Ignore catch (Exception ex) {
// Ignore
}
} }
} }
} }
@ -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 {

Loading…
Cancel
Save