use of org.apache.qpid.qmf2.common.SchemaClassId in project qpid by apache.
the class Console method getClasses.
/**
* Return a list of SchemaClassIds for all available Schema for the specified Agent.
* @param agent the Agent being queried
* @return a list of SchemaClassIds for all available Schema for the specified Agent.
*/
public List<SchemaClassId> getClasses(final Agent agent) {
// First look to see if there are cached results and if there are return those.
List<SchemaClassId> results = agent.getClasses();
if (results.size() > 0) {
return results;
}
String agentName = agent.getName();
results = new ArrayList<SchemaClassId>();
try {
MapMessage request = _syncSession.createMapMessage();
request.setJMSReplyTo(_replyAddress);
request.setStringProperty("x-amqp-0-10.app-id", "qmf2");
request.setStringProperty("method", "request");
request.setStringProperty("qmf.opcode", "_query_request");
request.setStringProperty("qpid.subject", agentName);
// Create a QMF Query for an "SCHEMA_ID" target
request.setObject("_what", "SCHEMA_ID");
// it would be somewhat unfortunate if their response got interleaved with ours!!
synchronized (this) {
_requester.send(request);
Message response = _responder.receive(_replyTimeout * 1000);
if (response == null) {
_log.info("No response received in getClasses()");
return Collections.emptyList();
}
if (AMQPMessage.isAMQPList(response)) {
List<Map> mapResults = AMQPMessage.getList(response);
for (Map content : mapResults) {
// new SchemaClassId(content).listValues();
results.add(new SchemaClassId(content));
}
} else if (AMQPMessage.isAMQPMap(response)) {
// Error responses are returned as MapMessages, though they are being ignored here.
// System.out.println("Console.getClasses() no results for " + agentName);
// QmfData exception = new QmfData(AMQPMessage.getMap(response));
// System.out.println(agentName + " " + exception.getStringValue("error_text"));
} else {
_log.info("getClasses() Received response message in incorrect format");
}
}
} catch (JMSException jmse) {
_log.info("JMSException {} caught in getClasses()", jmse.getMessage());
}
agent.setClasses(results);
return results;
}
Aggregations