stop.restart();
try {
String pubXml = blasterServer.publish(sessionId, msgUnit);
// Parse the returned XML string
PublishReturnQos q = new PublishReturnQos(glob, pubXml);
publishOid = q.getKeyOid();
log.info(" Returned oid=" + publishOid);
} catch(XmlBlasterException e) {
log.warning("XmlBlasterException: " + e.getMessage());
}
log.fine("Publishing done" + stop.nice());
}
//----------- get() the previous message OID -------
{
log.fine("get() using the exact oid ...");
String xmlKey = "<key oid='" + publishOid + "' queryType='EXACT'>\n" +
"</key>";
stop.restart();
MsgUnitRaw[] msgArr = null;
try {
msgArr = blasterServer.get(sessionId, xmlKey, "<qos></qos>");
log.info("Got " + msgArr.length + " messages:");
for (int ii=0; ii<msgArr.length; ii++) {
System.out.println(msgArr[ii].getKey() +
"\n################### RETURN CONTENT: ##################\n\n" +
new String(msgArr[ii].getContent()) +
"\n\n#######################################");
}
} catch(XmlBlasterException e) {
log.severe("XmlBlasterException: " + e.getMessage());
System.exit(1);
}
}
//----------- Construct a second message and publish it ---------
{
String xmlKey = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
"<key oid='Export-11' contentMime='text/plain'>" +
"<AGENT id='192.168.124.29' subId='1' type='generic'>" +
"<DRIVER id='ProgramExecute'>" +
"<EXECUTABLE>export</EXECUTABLE>" +
"<FILE>out.txt</FILE>" +
"</DRIVER>" +
"</AGENT>" +
"</key>";
String content = "Export program started";
MsgUnitRaw msgUnit = new MsgUnitRaw(xmlKey, content.getBytes(), "<qos></qos>");
log.fine("Publishing ...");
stop.restart();
try {
String pubXml = blasterServer.publish(sessionId, msgUnit);
// Parse the returned XML string
PublishReturnQos q = new PublishReturnQos(glob, pubXml);
publishOid = q.getKeyOid();
log.info(" Returned oid=" + publishOid);
} catch(XmlBlasterException e) {
log.warning("XmlBlasterException: " + e.getMessage());
}
log.fine("Publishing done" + stop.nice());