Upgrade to Artemis 2.20.0 and switch to Jakarta EE 9 JMS API

Closes gh-29203
pull/29295/head
Andy Wilkinson 3 years ago
parent 89e79e826e
commit 894f83fb13

@ -145,16 +145,11 @@ dependencies {
exclude group: "org.jboss.spec.javax.annotation", module: "jboss-annotations-api_1.3_spec" exclude group: "org.jboss.spec.javax.annotation", module: "jboss-annotations-api_1.3_spec"
} }
testImplementation("jakarta.xml.bind:jakarta.xml.bind-api") testImplementation("jakarta.xml.bind:jakarta.xml.bind-api")
testImplementation("org.apache.activemq:artemis-jms-client") { testImplementation("org.apache.activemq:artemis-jakarta-client") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jms_2.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
} }
testImplementation("org.apache.activemq:artemis-jms-server") { testImplementation("org.apache.activemq:artemis-jakarta-server") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jms_2.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jta_1.1_spec"
} }
testImplementation("org.apache.logging.log4j:log4j-to-slf4j") testImplementation("org.apache.logging.log4j:log4j-to-slf4j")
testImplementation("org.aspectj:aspectjrt") testImplementation("org.aspectj:aspectjrt")

@ -48,16 +48,11 @@ dependencies {
optional("jakarta.ws.rs:jakarta.ws.rs-api") optional("jakarta.ws.rs:jakarta.ws.rs-api")
optional("javax.cache:cache-api") optional("javax.cache:cache-api")
optional("javax.money:money-api") optional("javax.money:money-api")
optional("org.apache.activemq:artemis-jms-client") { optional("org.apache.activemq:artemis-jakarta-client") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jms_2.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
} }
optional("org.apache.activemq:artemis-jms-server") { optional("org.apache.activemq:artemis-jakarta-server") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jms_2.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
exclude group: "org.apache.geronimo.specs", module: "geronimo-jta_1.1_spec"
} }
optional("org.apache.commons:commons-dbcp2") { optional("org.apache.commons:commons-dbcp2") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.autoconfigure.jms.artemis; package org.springframework.boot.autoconfigure.jms.artemis;
import javax.jms.ConnectionFactory; import jakarta.jms.ConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,17 +16,14 @@
package org.springframework.boot.autoconfigure.jms.artemis; package org.springframework.boot.autoconfigure.jms.artemis;
import javax.jms.ConnectionFactory; import jakarta.jms.ConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.commons.pool2.PooledObject;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryFactory;
import org.springframework.boot.autoconfigure.jms.JmsProperties; import org.springframework.boot.autoconfigure.jms.JmsProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -83,19 +80,4 @@ class ArtemisConnectionFactoryConfiguration {
} }
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ JmsPoolConnectionFactory.class, PooledObject.class })
@ConditionalOnProperty(prefix = "spring.artemis.pool", name = "enabled", havingValue = "true")
static class PooledConnectionFactoryConfiguration {
@Bean(destroyMethod = "stop")
JmsPoolConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, ArtemisProperties properties) {
ActiveMQConnectionFactory connectionFactory = new ArtemisConnectionFactoryFactory(beanFactory, properties)
.createConnectionFactory(ActiveMQConnectionFactory.class);
return new JmsPoolConnectionFactoryFactory(properties.getPool())
.createPooledConnectionFactory(connectionFactory);
}
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,10 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryProperties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
/** /**
* Configuration properties for Artemis. * Configuration properties for Artemis.
@ -71,9 +69,6 @@ public class ArtemisProperties {
private final Embedded embedded = new Embedded(); private final Embedded embedded = new Embedded();
@NestedConfigurationProperty
private final JmsPoolConnectionFactoryProperties pool = new JmsPoolConnectionFactoryProperties();
public ArtemisMode getMode() { public ArtemisMode getMode() {
return this.mode; return this.mode;
} }
@ -142,10 +137,6 @@ public class ArtemisProperties {
return this.embedded; return this.embedded;
} }
public JmsPoolConnectionFactoryProperties getPool() {
return this.pool;
}
/** /**
* Configuration for an embedded Artemis server. * Configuration for an embedded Artemis server.
*/ */

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.boot.autoconfigure.jms.artemis; package org.springframework.boot.autoconfigure.jms.artemis;
import javax.jms.ConnectionFactory; import jakarta.jms.ConnectionFactory;
import javax.transaction.TransactionManager; import jakarta.transaction.TransactionManager;
import org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,9 +22,9 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.UUID; import java.util.UUID;
import javax.jms.ConnectionFactory; import jakarta.jms.ConnectionFactory;
import javax.jms.Message; import jakarta.jms.Message;
import javax.jms.TextMessage; import jakarta.jms.TextMessage;
import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
@ -43,7 +43,6 @@ import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationI
import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl; import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
@ -321,58 +320,6 @@ class ArtemisAutoConfigurationTests {
}); });
} }
@Test
void defaultPoolConnectionFactoryIsApplied() {
this.contextRunner.withPropertyValues("spring.artemis.pool.enabled=true").run((context) -> {
assertThat(context.getBeansOfType(JmsPoolConnectionFactory.class)).hasSize(1);
JmsPoolConnectionFactory connectionFactory = context.getBean(JmsPoolConnectionFactory.class);
JmsPoolConnectionFactory defaultFactory = new JmsPoolConnectionFactory();
assertThat(connectionFactory.isBlockIfSessionPoolIsFull())
.isEqualTo(defaultFactory.isBlockIfSessionPoolIsFull());
assertThat(connectionFactory.getBlockIfSessionPoolIsFullTimeout())
.isEqualTo(defaultFactory.getBlockIfSessionPoolIsFullTimeout());
assertThat(connectionFactory.getConnectionIdleTimeout())
.isEqualTo(defaultFactory.getConnectionIdleTimeout());
assertThat(connectionFactory.getMaxConnections()).isEqualTo(defaultFactory.getMaxConnections());
assertThat(connectionFactory.getMaxSessionsPerConnection())
.isEqualTo(defaultFactory.getMaxSessionsPerConnection());
assertThat(connectionFactory.getConnectionCheckInterval())
.isEqualTo(defaultFactory.getConnectionCheckInterval());
assertThat(connectionFactory.isUseAnonymousProducers()).isEqualTo(defaultFactory.isUseAnonymousProducers());
});
}
@Test
void customPoolConnectionFactoryIsApplied() {
this.contextRunner
.withPropertyValues("spring.artemis.pool.enabled=true", "spring.artemis.pool.blockIfFull=false",
"spring.artemis.pool.blockIfFullTimeout=64", "spring.artemis.pool.idleTimeout=512",
"spring.artemis.pool.maxConnections=256", "spring.artemis.pool.maxSessionsPerConnection=1024",
"spring.artemis.pool.timeBetweenExpirationCheck=2048",
"spring.artemis.pool.useAnonymousProducers=false")
.run((context) -> {
assertThat(context.getBeansOfType(JmsPoolConnectionFactory.class)).hasSize(1);
JmsPoolConnectionFactory connectionFactory = context.getBean(JmsPoolConnectionFactory.class);
assertThat(connectionFactory.isBlockIfSessionPoolIsFull()).isFalse();
assertThat(connectionFactory.getBlockIfSessionPoolIsFullTimeout()).isEqualTo(64);
assertThat(connectionFactory.getConnectionIdleTimeout()).isEqualTo(512);
assertThat(connectionFactory.getMaxConnections()).isEqualTo(256);
assertThat(connectionFactory.getMaxSessionsPerConnection()).isEqualTo(1024);
assertThat(connectionFactory.getConnectionCheckInterval()).isEqualTo(2048);
assertThat(connectionFactory.isUseAnonymousProducers()).isFalse();
});
}
@Test
void poolConnectionFactoryConfiguration() {
this.contextRunner.withPropertyValues("spring.artemis.pool.enabled:true").run((context) -> {
ConnectionFactory factory = getConnectionFactory(context);
assertThat(factory).isInstanceOf(JmsPoolConnectionFactory.class);
context.getSourceApplicationContext().close();
assertThat(factory.createConnection()).isNull();
});
}
private ConnectionFactory getConnectionFactory(AssertableApplicationContext context) { private ConnectionFactory getConnectionFactory(AssertableApplicationContext context) {
assertThat(context).hasSingleBean(ConnectionFactory.class).hasBean("jmsConnectionFactory"); assertThat(context).hasSingleBean(ConnectionFactory.class).hasBean("jmsConnectionFactory");
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class); ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);

@ -1,7 +1,7 @@
package org.test package org.test
@Grab("spring-boot-starter-artemis") @Grab("spring-boot-starter-artemis")
@Grab("artemis-jms-server") @Grab("artemis-jakarta-server")
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
@Log @Log

@ -1,5 +1,5 @@
@Grab("spring-boot-starter-artemis") @Grab("spring-boot-starter-artemis")
@Grab("artemis-jms-server") @Grab("artemis-jakarta-server")
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
@Log @Log

@ -31,28 +31,17 @@ bom {
] ]
} }
} }
library("Artemis", "2.19.0") { library("Artemis", "2.20.0") {
group("org.apache.activemq") { group("org.apache.activemq") {
modules = [ modules = [
"artemis-amqp-protocol", "artemis-amqp-protocol",
"artemis-commons" { "artemis-commons",
exclude group: "commons-logging", module: "commons-logging" "artemis-core-client",
}, "artemis-jakarta-client",
"artemis-core-client" { "artemis-jakarta-server",
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
},
"artemis-jms-client" {
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
},
"artemis-jms-server" {
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
},
"artemis-journal", "artemis-journal",
"artemis-selector", "artemis-selector",
"artemis-server" { "artemis-server",
exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.geronimo.specs", module: "geronimo-json_1.0_spec"
},
"artemis-service-extensions" "artemis-service-extensions"
] ]
} }

@ -43,19 +43,6 @@ By default, a `CachingConnectionFactory` wraps the native `ConnectionFactory` wi
session-cache-size: 5 session-cache-size: 5
---- ----
If you'd rather use native pooling, you can do so by adding a dependency to `org.messaginghub:pooled-jms` and configuring the `JmsPoolConnectionFactory` accordingly, as shown in the following example:
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
----
spring:
artemis:
pool:
enabled: true
max-connections: 50
----
See {spring-boot-autoconfigure-module-code}/jms/artemis/ArtemisProperties.java[`ArtemisProperties`] for more supported options.
No JNDI lookup is involved, and destinations are resolved against their names, using either the `name` attribute in the Artemis configuration or the names provided through configuration. No JNDI lookup is involved, and destinations are resolved against their names, using either the `name` attribute in the Artemis configuration or the names provided through configuration.

@ -7,7 +7,7 @@ description = "Starter for JMS messaging using Apache Artemis"
dependencies { dependencies {
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api("org.springframework:spring-jms") api("org.springframework:spring-jms")
api("org.apache.activemq:artemis-jms-client") { api("org.apache.activemq:artemis-jakarta-client") {
exclude group: "commons-logging", module: "commons-logging" exclude group: "commons-logging", module: "commons-logging"
} }
} }

Loading…
Cancel
Save