{
log.info("Hit a key to subscribe on topic " + oid);
try { System.in.read(); } catch(java.io.IOException e) {}
SubscribeKey sk = new SubscribeKey(glob, oid);
SubscribeQos sq = new SubscribeQos(glob);
SubscribeReturnQos subRet = xmlBlasterAccess.subscribe(sk, sq);
log.info("Subscribed for " + sk.toXml() + "\n" + sq.toXml() + " return:\n" + subRet.toXml());
log.info("Hit a key to publish '" + oid + "'");
try { System.in.read(); } catch(java.io.IOException e) {}
MsgUnit msgUnit = new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>");
PublishReturnQos publishReturnQos = xmlBlasterAccess.publish(msgUnit);
log.info("Successfully published message to xmlBlaster, msg=" + msgUnit.toXml() + "\n returned QoS=" + publishReturnQos.toXml());
try { Thread.sleep(1000L); } catch( InterruptedException i) {} // wait for update
{
log.info("Hit a key to 3 times publishOneway '" + oid + "'");
try { System.in.read(); } catch(java.io.IOException e) {}
MsgUnit[] msgUnitArr = new MsgUnit[] {
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>"),
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>"),
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>")
};
xmlBlasterAccess.publishOneway(msgUnitArr);
log.info("Successfully published " + msgUnitArr.length + " messages oneway");
try { Thread.sleep(1000L); } catch( InterruptedException i) {} // wait for update
}
{
log.info("Hit a key to 3 times publishArr '" + oid + "'");
try { System.in.read(); } catch(java.io.IOException e) {}
MsgUnit[] msgUnitArr = new MsgUnit[] {
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>"),
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>"),
new MsgUnit(glob, "<key oid='"+oid+"'/>", "Hi".getBytes(), "<qos><persistent>true</persistent></qos>")
};
PublishReturnQos[] retArr = xmlBlasterAccess.publishArr(msgUnitArr);
log.info("Successfully published " + retArr.length + " acknowledged messages");
try { Thread.sleep(1000L); } catch( InterruptedException i) {} // wait for update
}
{
log.info("Hit a key to get '" + oid + "'");
try { System.in.read(); } catch(java.io.IOException e) {}
GetKey gk = new GetKey(glob, oid);
GetQos gq = new GetQos(glob);
MsgUnit[] msgs = xmlBlasterAccess.get(gk, gq);
log.info("Successfully got message from xmlBlaster, msg=" + msgs[0].toXml());
}
int numGetCached = 4;
xmlBlasterAccess.createSynchronousCache(100);
for (int i=0; i<numGetCached; i++) {
log.info("Hit a key to getCached '" + oid + "' #"+i+"/"+numGetCached);
try { System.in.read(); } catch(java.io.IOException e) {}
GetKey gk = new GetKey(glob, oid);
GetQos gq = new GetQos(glob);
MsgUnit[] msgs = xmlBlasterAccess.getCached(gk, gq);
log.info("Successfully got message from xmlBlaster, msg=" + msgs[0].toXml());
}
log.info("Hit a key to unSubscribe on topic '" + oid + "' and '" + subRet.getSubscriptionId() + "'");
try { System.in.read(); } catch(java.io.IOException e) {}
UnSubscribeKey uk = new UnSubscribeKey(glob, subRet.getSubscriptionId());
UnSubscribeQos uq = new UnSubscribeQos(glob);
UnSubscribeReturnQos[] unSubRet = xmlBlasterAccess.unSubscribe(uk, uq);
log.info("UnSubscribed for " + uk.toXml() + "\n" + uq.toXml() + " return:\n" + unSubRet[0].toXml());
log.info("Hit a key to erase on topic " + oid);