From c3fbd1b9e479f87898e0acd53f386d588c997632 Mon Sep 17 00:00:00 2001 From: Ingo Weiss Date: Wed, 25 Apr 2018 09:44:15 +0100 Subject: [PATCH] [ARTEMIS-1819] Missing fields on listAllConsumersAsJSON, listConsumersAsJSON and listConnectionsAsJSON Issue: https://issues.apache.org/jira/browse/ARTEMIS-1819 --- .../impl/ActiveMQServerControlImpl.java | 26 +++++++++++++++++++ .../management/ActiveMQServerControlTest.java | 14 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index 58f2613185..f4537a0ec0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -53,6 +53,7 @@ import org.apache.activemq.artemis.api.core.JsonUtil; import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.BridgeControl; @@ -1831,6 +1832,19 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active for (RemotingConnection connection : connections) { JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("connectionID", connection.getID().toString()).add("clientAddress", connection.getRemoteAddress()).add("creationTime", connection.getCreationTime()).add("implementation", connection.getClass().getSimpleName()).add("sessionCount", server.getSessions(connection.getID().toString()).size()); + + List sessions = server.getSessions(connection.getID().toString()); + + if (sessions.size() > 0) { + if (sessions.get(0).getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null) { + obj.add("clientID", sessions.get(0).getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY)); + } else { + obj.add("clientID", ""); + } + } else { + obj.add("clientID", ""); + } + array.add(obj); } return array.build().toString(); @@ -1948,6 +1962,18 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active obj.add("filter", consumer.getFilter().getFilterString().toString()); } + obj.add("destinationName", consumer.getQueue().getAddress().toString()); + + if (consumer.getQueueType().getType() == 0) { + obj.add("destinationType", "topic"); + } else if (consumer.getQueueType().getType() == 1) { + obj.add("destinationType", "queue"); + } else { + obj.add("destinationType", ""); + } + + obj.add("durable", consumer.getQueue().isDurable()); + return obj.build(); } 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 a16e72f66d..d290ec2e18 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 @@ -1312,11 +1312,13 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertTrue(first.getString("clientAddress").length() > 0); Assert.assertTrue(first.getJsonNumber("creationTime").longValue() > 0); Assert.assertEquals(0, first.getJsonNumber("sessionCount").longValue()); + Assert.assertEquals("", first.getString("clientID")); Assert.assertTrue(second.getString("connectionID").length() > 0); Assert.assertTrue(second.getString("clientAddress").length() > 0); Assert.assertTrue(second.getJsonNumber("creationTime").longValue() > 0); Assert.assertEquals(1, second.getJsonNumber("sessionCount").longValue()); + Assert.assertEquals("", second.getString("clientID")); } @Test @@ -1359,6 +1361,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(false, first.getBoolean("browseOnly")); Assert.assertTrue(first.getJsonNumber("creationTime").longValue() > 0); Assert.assertEquals(0, first.getJsonNumber("deliveringCount").longValue()); + Assert.assertEquals(queueName.toString(), first.getString("destinationName")); + Assert.assertEquals("queue", first.getString("destinationType")); + Assert.assertFalse(first.getBoolean("durable")); Assert.assertNotNull(second.getJsonNumber("consumerID").longValue()); Assert.assertTrue(second.getString("connectionID").length() > 0); @@ -1372,6 +1377,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(0, second.getJsonNumber("deliveringCount").longValue()); Assert.assertTrue(second.getString("filter").length() > 0); Assert.assertEquals(filter, second.getString("filter")); + Assert.assertEquals(queueName.toString(), second.getString("destinationName")); + Assert.assertEquals("queue", second.getString("destinationType")); + Assert.assertFalse(second.getBoolean("durable")); } @Test @@ -1436,6 +1444,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(queueName.toString(), first.getString("queueName")); Assert.assertEquals(false, first.getBoolean("browseOnly")); Assert.assertEquals(0, first.getJsonNumber("deliveringCount").longValue()); + Assert.assertEquals(queueName.toString(), first.getString("destinationName")); + Assert.assertEquals("queue", first.getString("destinationType")); + Assert.assertFalse(first.getBoolean("durable")); Assert.assertTrue(second.getJsonNumber("creationTime").longValue() > 0); Assert.assertNotNull(second.getJsonNumber("consumerID").longValue()); @@ -1447,6 +1458,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(queueName.toString(), second.getString("queueName")); Assert.assertEquals(false, second.getBoolean("browseOnly")); Assert.assertEquals(0, second.getJsonNumber("deliveringCount").longValue()); + Assert.assertEquals(queueName.toString(), second.getString("destinationName")); + Assert.assertEquals("queue", second.getString("destinationType")); + Assert.assertFalse(second.getBoolean("durable")); } @Test