Search in sources :

Example 1 with ServerSession

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();
    }
}
Also used : ServerSession(org.apache.activemq.artemis.core.server.ServerSession) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 2 with ServerSession

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;
}
Also used : ServerSession(org.apache.activemq.artemis.core.server.ServerSession) ServerConsumer(org.apache.activemq.artemis.core.server.ServerConsumer)

Example 3 with ServerSession

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;
}
Also used : ServerSession(org.apache.activemq.artemis.core.server.ServerSession)

Example 4 with ServerSession

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();
    }
}
Also used : ServerSession(org.apache.activemq.artemis.core.server.ServerSession) ConsumerView(org.apache.activemq.artemis.core.management.impl.view.ConsumerView) ServerConsumer(org.apache.activemq.artemis.core.server.ServerConsumer) HashSet(java.util.HashSet)

Example 5 with ServerSession

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;
}
Also used : ServerSession(org.apache.activemq.artemis.core.server.ServerSession) JsonObjectBuilder(javax.json.JsonObjectBuilder) Date(java.util.Date)

Aggregations

ServerSession (org.apache.activemq.artemis.core.server.ServerSession)32 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)11 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)8 ServerConsumer (org.apache.activemq.artemis.core.server.ServerConsumer)7 HashSet (java.util.HashSet)6 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)5 Test (org.junit.Test)5 Date (java.util.Date)4 JsonArrayBuilder (javax.json.JsonArrayBuilder)4 JsonObjectBuilder (javax.json.JsonObjectBuilder)4 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)4 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)4 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)4 LinkedList (java.util.LinkedList)3 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)3 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2