[prev in list] [next in list] [prev in thread] [next in thread]
List: activemq-commits
Subject: (activemq-artemis) branch main updated: ARTEMIS-1769 return JMS Session's ClientID via JMX
From: jbertram () apache ! org
Date: 2024-04-27 14:39:00
Message-ID: 171422874051.1711471.5339812237791537464 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]
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/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 614b5cb32f ARTEMIS-1769 return JMS Session's ClientID via JMX
614b5cb32f is described below
commit 614b5cb32f8df9cd2824fdfe3b1e2cbdb44f2d6a
Author: Justin Bertram <jbertram@apache.org>
AuthorDate: Sat Apr 13 22:57:02 2024 -0500
ARTEMIS-1769 return JMS Session's ClientID via JMX
---
.../core/management/impl/view/SessionView.java | 5 ++++-
.../management/ActiveMQServerControlTest.java | 24 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
index fedc96f44b..182d84285e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
@@ -46,7 +46,8 @@ public class SessionView extends \
ActiveMQAbstractView<ServerSession> {
.add(SessionField.CREATION_TIME.getName(), new \
Date(session.getCreationTime()).toString())
.add(SessionField.CONSUMER_COUNT.getName(), session.getConsumerCount())
.add(SessionField.PRODUCER_COUNT.getName(), session.getProducerCount())
- .add(SessionField.CONNECTION_ID.getName(), \
session.getConnectionID().toString()); + \
.add(SessionField.CONNECTION_ID.getName(), session.getConnectionID().toString()) + \
.add(SessionField.CLIENT_ID.getName(), \
session.getRemotingConnection().getClientID()); return obj;
}
@@ -69,6 +70,8 @@ public class SessionView extends \
ActiveMQAbstractView<ServerSession> { return session.getProducerCount();
case CONNECTION_ID:
return session.getConnectionID();
+ case CLIENT_ID:
+ return session.getRemotingConnection().getClientID();
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java \
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index c7ad640605..be1cb95741 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -82,6 +82,7 @@ import \
org.apache.activemq.artemis.core.config.impl.SecurityConfiguration; import \
org.apache.activemq.artemis.core.management.impl.view.ConnectionField; import \
org.apache.activemq.artemis.core.management.impl.view.ConsumerField; import \
org.apache.activemq.artemis.core.management.impl.view.ProducerField; +import \
org.apache.activemq.artemis.core.management.impl.view.SessionField; import \
org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterManagerImpl; \
import org.apache.activemq.artemis.core.persistence.OperationContext; import \
org.apache.activemq.artemis.core.persistence.config.PersistedDivertConfiguration; @@ \
-4330,6 +4331,29 @@ public class ActiveMQServerControlTest extends ManagementTestBase \
{ }
}
+ @Test
+ public void testListSessionsJmsClientID() throws Exception {
+ final String clientId = RandomUtil.randomString();
+
+ ActiveMQServerControl serverControl = createManagementControl();
+
+ ConnectionFactory cf = new ActiveMQConnectionFactory("vm://0");
+ try (Connection c = cf.createConnection()) {
+ c.setClientID(clientId);
+ c.createSession();
+ String filter = createJsonFilter(SessionField.CLIENT_ID.getName(), \
"EQUALS", clientId); + String json = serverControl.listSessions(filter, 1, \
50); + System.out.println(json);
+ JsonObject sessions = JsonUtil.readJsonObject(json);
+ JsonArray array = (JsonArray) sessions.get("data");
+
+ Assert.assertEquals("number of sessions returned from query", 2, \
array.size()); + JsonObject jsonSession = array.getJsonObject(0);
+
+ Assert.assertEquals("wrong client ID returned", clientId, \
jsonSession.getString(SessionField.CLIENT_ID.getName())); + }
+ }
+
@RetryMethod(retries = 2) // the list of connections eventually comes from a \
hashmap on a different order. Which is fine but makes the test fail. a Retry is ok \
@Test public void testListConnections() throws Exception {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic