Search in sources :

Example 16 with Subscription

use of org.apache.qpid.qmf2.agent.Subscription in project qpid by apache.

the class ConnectionAudit method checkExistingSubscriptions.

/**
     * When we start up we need to check any subscriptions that already exist against the whitelist.
     * Subsequent checks are made only when we receive new subscribe events.
     */
private void checkExistingSubscriptions() {
    readWhitelist();
    List<QmfConsoleData> subscriptions = _console.getObjects("org.apache.qpid.broker", "subscription");
    for (QmfConsoleData subscription : subscriptions) {
        QmfConsoleData queue = dereference(subscription.getRefValue("queueRef"));
        QmfConsoleData session = dereference(subscription.getRefValue("sessionRef"));
        QmfConsoleData connection = dereference(session.getRefValue("connectionRef"));
        String queueName = queue.getStringValue("name");
        String address = connection.getStringValue("address");
        String timestamp = new Date(subscription.getCreateTime() / 1000000l).toString();
        validateQueue(queueName, address, timestamp);
    }
}
Also used : QmfConsoleData(org.apache.qpid.qmf2.console.QmfConsoleData) Date(java.util.Date)

Example 17 with Subscription

use of org.apache.qpid.qmf2.agent.Subscription in project qpid by apache.

the class ConnectionLogger method logConnectionInformation.

/**
     * Logs audit information about each connection made to the broker
     *
     * Obtains connection, session and subscription objects and iterates in turn through these comparing
     * references to find the subscriptions association with sessions and sessions associated with
     * connections. Ultimately it then uses logQueueInformation to display the queues associated with
     * each subscription.
     */
private void logConnectionInformation() {
    System.out.println("\n\n**** ConnectionLogger: Logging current connection information ****");
    List<QmfConsoleData> connections = _console.getObjects("org.apache.qpid.broker", "connection");
    List<QmfConsoleData> sessions = _console.getObjects("org.apache.qpid.broker", "session");
    List<QmfConsoleData> subscriptions = _console.getObjects("org.apache.qpid.broker", "subscription");
    for (QmfConsoleData connection : connections) {
        System.out.printf("\nConnection '%s'\n", connection.getStringValue("address"));
        String[] properties = { "authIdentity", "remoteProcessName", "federationLink" };
        for (String p : properties) {
            System.out.println(p + ": " + connection.getStringValue(p));
        }
        System.out.println("createTimestamp: " + new Date(connection.getCreateTime() / 1000000l));
        ObjectId connectionId = connection.getObjectId();
        for (QmfConsoleData session : sessions) {
            // Iterate through all session objects
            ObjectId connectionRef = session.getRefValue("connectionRef");
            if (connectionRef.equals(connectionId)) {
                // But only select sessions that are associated with the connection under consideration.
                System.out.printf("Session '%s'\n", session.getStringValue("name"));
                int subscriptionCount = 0;
                ObjectId sessionId = session.getObjectId();
                for (QmfConsoleData subscription : subscriptions) {
                    // Iterate through all subscription objects
                    ObjectId sessionRef = subscription.getRefValue("sessionRef");
                    if (sessionRef.equals(sessionId)) {
                        // But only select subscriptions that are associated with the session under consideration.
                        subscriptionCount++;
                        ObjectId queueRef = subscription.getRefValue("queueRef");
                        if (_logQueues) {
                            logQueueInformation(queueRef);
                        }
                    }
                }
                if (subscriptionCount == 0) {
                    System.out.println("    ** No Subscriptions for this Session - probably a producer only Session **");
                }
            }
        }
    }
}
Also used : ObjectId(org.apache.qpid.qmf2.common.ObjectId) QmfConsoleData(org.apache.qpid.qmf2.console.QmfConsoleData) Date(java.util.Date)

Aggregations

QmfException (org.apache.qpid.qmf2.common.QmfException)9 ObjectId (org.apache.qpid.qmf2.common.ObjectId)8 QmfQuery (org.apache.qpid.qmf2.common.QmfQuery)6 JMSException (javax.jms.JMSException)5 Handle (org.apache.qpid.qmf2.common.Handle)5 QmfData (org.apache.qpid.qmf2.common.QmfData)4 QmfConsoleData (org.apache.qpid.qmf2.console.QmfConsoleData)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 MapMessage (javax.jms.MapMessage)3 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)3 QmfEvent (org.apache.qpid.qmf2.common.QmfEvent)3 SchemaClassId (org.apache.qpid.qmf2.common.SchemaClassId)3 AddressParser (org.apache.qpid.messaging.util.AddressParser)2 Subscription (org.apache.qpid.qmf2.agent.Subscription)2 AgentHeartbeatWorkItem (org.apache.qpid.qmf2.console.AgentHeartbeatWorkItem)2 AgentRestartedWorkItem (org.apache.qpid.qmf2.console.AgentRestartedWorkItem)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1