This closes #669

This commit is contained in:
Clebert Suconic 2016-07-26 14:31:50 -04:00
commit 0d69b0e857
4 changed files with 29 additions and 13 deletions

View File

@ -40,8 +40,8 @@ public class JMSConnectionInfo {
JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
for (int i = 0; i < array.size(); i++) {
JsonObject obj = array.getJsonObject(i);
String cid = obj.isNull("clientID") ? null : obj.getString("clientID");
String uname = obj.isNull("principal") ? null : obj.getString("principal");
String cid = obj.containsKey("clientID") ? obj.getString("clientID") : null;
String uname = obj.containsKey("principal") ? obj.getString("principal") : null;
JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"),
obj.getJsonNumber("creationTime").longValue(),

View File

@ -54,7 +54,7 @@ public class JMSConsumerInfo {
JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
for (int i = 0; i < array.size(); i++) {
JsonObject sub = array.getJsonObject(i);
JMSConsumerInfo info = new JMSConsumerInfo(sub.getString("consumerID"), sub.getString("connectionID"),
JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(), sub.getString("connectionID"),
sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"),
sub.getJsonNumber("creationTime").longValue(),
sub.getBoolean("durable"), sub.getString("filter", null));

View File

@ -620,15 +620,20 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
for (RemotingConnection connection : connections) {
ServerSession session = jmsSessions.get(connection.getID());
if (session != null) {
JsonObject obj = Json.createObjectBuilder()
JsonObjectBuilder objectBuilder = Json.createObjectBuilder()
.add("connectionID", connection.getID().toString())
.add("clientAddress", connection.getRemoteAddress())
.add("creationTime", connection.getCreationTime())
// Notice: this will be null when the user haven't set the client-id
.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY))
.add("principal", session.getUsername())
.build();
array.add(obj);
.add("creationTime", connection.getCreationTime());
if (session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null) {
objectBuilder.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY));
}
if (session.getUsername() != null) {
objectBuilder.add("principal", session.getUsername());
}
array.add(objectBuilder.build());
}
}
return array.build().toString();
@ -651,8 +656,15 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
for (RemotingConnection connection : connections) {
if (connectionID.equals(connection.getID().toString())) {
List<ServerSession> sessions = server.getActiveMQServer().getSessions(connectionID);
JsonArray jsonSessions = toJsonArray(sessions);
array.add(jsonSessions);
for (ServerSession session : sessions) {
Set<ServerConsumer> consumers = session.getServerConsumers();
for (ServerConsumer consumer : consumers) {
JsonObject obj = toJSONObject(consumer);
if (obj != null) {
array.add(obj);
}
}
}
}
}
return array.build().toString();

View File

@ -1398,8 +1398,12 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
JsonObjectBuilder obj = Json.createObjectBuilder()
.add("sessionID", sess.getName())
.add("creationTime", sess.getCreationTime())
.add("principal", sess.getValidatedUser())
.add("consumerCount", sess.getServerConsumers().size());
if (sess.getValidatedUser() != null) {
obj.add("principal", sess.getValidatedUser());
}
array.add(obj);
}
}