try {
log.info("Connecting ...");
con1 = glob1.getXmlBlasterAccess();
ConnectQos qos = new ConnectQos(glob1, name1, "secret");
assertInUpdate = null;
con1.connect(qos, new I_Callback() { // Login to xmlBlaster, register for updates
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
log.info("****** Con1 update arrived" + updateKey.toXml() + updateQos.toXml());
assertInUpdate = glob1.getId() + ": Did not expect message update in first handler";
fail(assertInUpdate); // This is routed to server, not to junit
return "";
}
});
SubscribeKey sk = new SubscribeKey(glob1, oid);
SubscribeQos sq = new SubscribeQos(glob1);
con1.subscribe(sk.toXml(), sq.toXml());
try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
assertTrue(assertInUpdate, assertInUpdate == null);
Client.shutdownCb(con1, Client.Shutdown.LEAVE_SERVER);
log.info("############ Con1 is down");
assertInUpdate = null;
con2 = glob2.getXmlBlasterAccess();
qos = new ConnectQos(glob2); // force a new session
con2.connect(qos, new I_Callback() { // Login to xmlBlaster, register for updates
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
log.info("****** Con2 update arrived" + updateKey.toXml() + updateQos.toXml());
assertInUpdate = glob2.getId() + "Reveiving asynchronous message '" + updateKey.getOid() + "' in second handler";
log.info(assertInUpdate);
return "";
}
});
sk = new SubscribeKey(glob2, oid);
sq = new SubscribeQos(glob2);
con2.subscribe(sk.toXml(), sq.toXml());
sk = new SubscribeKey(glob2, Constants.OID_DEAD_LETTER);
sq = new SubscribeQos(glob2);
con2.subscribe(sk.toXml(), sq.toXml(), new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
deadMessageCounter++;
log.info("****** Reveiving asynchronous message '" + updateKey.getOid() + "' in deadMessage handler, content=" + new String(content));
assertEquals("No dead letter received", Constants.OID_DEAD_LETTER, updateKey.getOid());
return "";