This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 90e3db6cc8 ARTEMIS-5976 Pass clientID to session creation in
ActiveMQResourceAdapter
90e3db6cc8 is described below
commit 90e3db6cc86ed2730f74b18c39ea6f3cbfb01148
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Mon Mar 30 11:57:45 2026 +0200
ARTEMIS-5976 Pass clientID to session creation in ActiveMQResourceAdapter
The ActiveMQResourceAdapter.createSession() method was not passing the
clientID parameter when creating sessions via ClientSessionFactory,
resulting in remoting connection without the clientID property set on the
server side.
---
.../artemis/ra/ActiveMQResourceAdapter.java | 10 ++--
.../tests/integration/ra/ResourceAdapterTest.java | 63 ++++++++++++++++++++++
2 files changed, 68 insertions(+), 5 deletions(-)
diff --git
a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
index cbf45b6b56..831fa3f7d9 100644
---
a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
+++
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java
@@ -1030,20 +1030,20 @@ public class ActiveMQResourceAdapter implements
ResourceAdapter, Serializable {
// If transacted we need to send the ack flush as soon as possible as
if any transaction times out, we need
// the ack on the server already
if (useLocalTx) {
- result = parameterFactory.createSession(user, pass, false, false,
false, false, 0);
+ result = parameterFactory.createSession(user, pass, false, false,
false, false, 0, getClientID());
} else {
- result = parameterFactory.createSession(user, pass, true, false,
false, false, 0);
+ result = parameterFactory.createSession(user, pass, true, false,
false, false, 0, getClientID());
}
} else {
if (preAck != null && preAck) {
- result = parameterFactory.createSession(user, pass, false, true,
true, true, -1);
+ result = parameterFactory.createSession(user, pass, false, true,
true, true, -1, getClientID());
} else {
// only auto ack and dups ok are supported
result = switch (ackMode) {
- case Session.AUTO_ACKNOWLEDGE ->
parameterFactory.createSession(user, pass, false, true, true, false, 0);
+ case Session.AUTO_ACKNOWLEDGE ->
parameterFactory.createSession(user, pass, false, true, true, false, 0,
getClientID());
case Session.DUPS_OK_ACKNOWLEDGE -> {
int actDupsOkBatchSize = dupsOkBatchSize != null ?
dupsOkBatchSize : ActiveMQClient.DEFAULT_ACK_BATCH_SIZE;
- yield parameterFactory.createSession(user, pass, false,
true, true, false, actDupsOkBatchSize);
+ yield parameterFactory.createSession(user, pass, false,
true, true, false, actDupsOkBatchSize, getClientID());
}
default -> throw new IllegalArgumentException("Invalid ackmode:
" + ackMode);
};
diff --git
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
index 96961cd014..7b65240bdc 100644
---
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
+++
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java
@@ -891,6 +891,69 @@ public class ResourceAdapterTest extends
ActiveMQRATestBase {
}
+ @Test
+ public void testClientIDPassedToSessionWithUseLocalTx() throws Exception {
+ testClientIDPassedToSession("testClientID", ra ->
ra.setUseLocalTx(true), spec -> { }, false);
+ }
+
+ @Test
+ public void testClientIDPassedToSessionWithDeliveryTransacted() throws
Exception {
+ testClientIDPassedToSession("testClientIDTransacted", ra -> { }, spec ->
{ }, true);
+ }
+
+ @Test
+ public void testClientIDPassedToSessionWithPreAck() throws Exception {
+ testClientIDPassedToSession("testClientIDPreAck", ra ->
ra.setPreAcknowledge(true), spec -> { }, false);
+ }
+
+ @Test
+ public void testClientIDPassedToSessionWithDupsOkAck() throws Exception {
+ testClientIDPassedToSession("testClientIDDupsOk",
+ ra -> ra.setDupsOKBatchSize(100),
+ spec -> spec.setAcknowledgeMode("Dups-ok-acknowledge"),
+ false);
+ }
+
+ @Test
+ public void testClientIDPassedToSessionWithAutoAck() throws Exception {
+ testClientIDPassedToSession("testClientIDAutoAck",
+ ra -> { },
+ spec -> spec.setAcknowledgeMode("Auto-acknowledge"),
+ false);
+ }
+
+ private void testClientIDPassedToSession(String clientID,
+
java.util.function.Consumer<ActiveMQResourceAdapter> raConfigurator,
+
java.util.function.Consumer<ActiveMQActivationSpec> specConfigurator,
+ boolean deliveryTransacted)
throws Exception {
+ ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
+ ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ ra.setClientID(clientID);
+ raConfigurator.accept(ra);
+ ra.start(new BootstrapContext());
+
+ ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+ spec.setResourceAdapter(ra);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+ specConfigurator.accept(spec);
+
+ CountDownLatch latch = new CountDownLatch(1);
+ DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
+ DummyMessageEndpointFactory endpointFactory = new
DummyMessageEndpointFactory(endpoint, deliveryTransacted);
+
+ ra.endpointActivation(endpointFactory, spec);
+
+ // Verify the clientID is set on the server-side remoting connection
+ assertFalse(server.getRemotingService().getConnections().isEmpty());
+
assertTrue(server.getRemotingService().getConnections().stream().allMatch(
+ remotingConnection ->
clientID.equals(remotingConnection.getClientID())));
+
+ ra.stop();
+ assertTrue(endpoint.released);
+ }
+
@Override
public boolean useSecurity() {
return false;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]