final String oid = isDirtyReadTest ? "PublishToBilbo-DirtyRead" : "PublishToBilbo-NODirtyRead";
SubscribeKey sk;
SubscribeQos sq;
PublishKey pk;
PublishQos pq;
PublishReturnQos prq;
MsgUnit msgUnit;
try {
System.err.println(ME+"->Connect to frodo ...");
frodoCon = serverHelper.connect(serverHelper.getFrodoGlob(), new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
assertInUpdate = serverHelper.getFrodoGlob().getId() + ": Receive unexpected message '" + updateKey.getOid() + "'";
return "";
}
});
try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
assertTrue(assertInUpdate, assertInUpdate == null);
System.err.println(ME+"->Subscribe '" + oid + "' from frodo ...");
sk = new SubscribeKey(glob, oid);
sk.setDomain(domain);
sq = new SubscribeQos(glob);
frodoCon.subscribe(sk.toXml(), sq.toXml(), new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
log.info("Reveiving asynchronous message '" + updateKey.getOid() + "' in " + oid + " handler");
updateCounterFrodo++;
assertInUpdate = null;
return "";
}
}); // subscribe with our specific update handler
try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
assertTrue(assertInUpdate, assertInUpdate == null);
assertInUpdate = null;
System.err.println(ME+"->Check publish '" + oid + "', frodo should get it ...");
pk = new PublishKey(glob, oid, "text/plain", "1.0", domain);
pq = new PublishQos(glob);
msgUnit = new MsgUnit(pk, contentStr.getBytes(), pq);
prq = frodoCon.publish(msgUnit);
log.info("Published message of domain='" + pk.getDomain() + "' and content='" + contentStr +
"' to xmlBlaster node with IP=" + serverHelper.getFrodoGlob().getProperty().get("bootstrapPort",0) +
", the returned QoS is: " + prq.getKeyOid());
try { Thread.sleep(2000); } catch( InterruptedException i) {} // Wait some time
assertEquals("frodo has not received message", 1, updateCounterFrodo);