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);
}
}
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 **");
}
}
}
}
}
Aggregations