[ARTEMIS-1819] Missing fields on listAllConsumersAsJSON, listConsumersAsJSON and listConnectionsAsJSON

Issue: https://issues.apache.org/jira/browse/ARTEMIS-1819
This commit is contained in:
Ingo Weiss 2018-04-25 09:44:15 +01:00 committed by Clebert Suconic
parent 7bcf71a5d6
commit c3fbd1b9e4
2 changed files with 40 additions and 0 deletions

View File

@ -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<ServerSession> 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();
}

View File

@ -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