use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method listSessions.
@Override
public String[] listSessions(final String connectionID) {
checkStarted();
clearIO();
try {
List<ServerSession> sessions = server.getSessions(connectionID);
String[] sessionIDs = new String[sessions.size()];
int i = 0;
for (ServerSession serverSession : sessions) {
sessionIDs[i++] = serverSession.getName();
}
return sessionIDs;
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method closeConsumerWithID.
@Override
public boolean closeConsumerWithID(final String sessionID, final String ID) throws Exception {
checkStarted();
clearIO();
try {
Set<ServerSession> sessions = server.getSessions();
for (ServerSession session : sessions) {
if (session.getName().equals(sessionID.toString())) {
Set<ServerConsumer> serverConsumers = session.getServerConsumers();
for (ServerConsumer serverConsumer : serverConsumers) {
if (serverConsumer.sequentialID() == Long.valueOf(ID)) {
serverConsumer.disconnect();
return true;
}
}
}
}
} finally {
blockOnIO();
}
return false;
}
use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method closeSessionWithID.
@Override
public boolean closeSessionWithID(final String connectionID, final String ID) throws Exception {
checkStarted();
clearIO();
try {
List<ServerSession> sessions = server.getSessions(connectionID);
for (ServerSession session : sessions) {
if (session.getName().equals(ID.toString())) {
session.close(true);
return true;
}
}
} finally {
blockOnIO();
}
return false;
}
use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method listConsumers.
@Override
public String listConsumers(String options, int page, int pageSize) throws Exception {
checkStarted();
clearIO();
try {
Set<ServerConsumer> consumers = new HashSet();
for (ServerSession session : server.getSessions()) {
consumers.addAll(session.getServerConsumers());
}
ConsumerView view = new ConsumerView(server);
view.setCollection(consumers);
view.setOptions(options);
return view.getResultsAsJson(page, pageSize);
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.server.ServerSession in project activemq-artemis by apache.
the class ConsumerView method toJson.
@Override
public JsonObjectBuilder toJson(ServerConsumer consumer) {
ServerSession session = server.getSessionByID(consumer.getSessionID());
// if session is not available then consumer is not in valid state - ignore
if (session == null) {
return null;
}
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(consumer.getSequentialID())).add("session", toString(consumer.getSessionName())).add("clientID", toString(consumer.getConnectionClientID())).add("user", toString(session.getUsername())).add("protocol", toString(consumer.getConnectionProtocolName())).add("queue", toString(consumer.getQueueName())).add("queueType", toString(consumer.getQueueType()).toLowerCase()).add("address", toString(consumer.getQueueAddress())).add("localAddress", toString(consumer.getConnectionLocalAddress())).add("remoteAddress", toString(consumer.getConnectionRemoteAddress())).add("creationTime", new Date(consumer.getCreationTime()).toString());
return obj;
}
Aggregations