try {
log.info("============ STEP 1: Start publisher");
conSnd = glob.getXmlBlasterAccess();
ConnectQos qosPub = new ConnectQos(glob);
ConnectReturnQos crqPub = conSnd.connect(qosPub, null); // Login to xmlBlaster, no updates
log.info("Connect success as " + crqPub.getSessionName());
int numPub = 8;
log.info("============ STEP 2: Publish " + numPub + " PtP messages");
MsgUnit[] sentArr = new MsgUnit[numPub];
PublishReturnQos[] sentQos = new PublishReturnQos[numPub];
for(int i=0; i<numPub; i++) {
PublishKey pk = new PublishKey(glob, oid, "text/xml", "1.0");
pk.setClientTags("<org.xmlBlaster><demo/></org.xmlBlaster>");
PublishQos pq = new PublishQos(glob);
pq.setPriority(PriorityEnum.NORM_PRIORITY);
pq.setPersistent(true);
Destination dest = new Destination(glob, new SessionName(glob, sessionNameRcv));
dest.forceQueuing(true);
pq.addDestination(dest);
pq.setForceUpdate(true);
pq.setSubscribable(false);
pq.setLifeTime(60000L);
if (i == 0) {
TopicProperty topicProperty = new TopicProperty(glob);
topicProperty.setDestroyDelay(60000L);
topicProperty.setCreateDomEntry(true);
topicProperty.setReadonly(false);
topicProperty.getHistoryQueueProperty().setMaxEntries(numPub+5);
pq.setTopicProperty(topicProperty);
log.info("Added TopicProperty on first publish: " + topicProperty.toXml());
}
byte[] content = "Hello".getBytes();
MsgUnit msgUnit = new MsgUnit(pk, content, pq);
sentArr[i] = msgUnit;
PublishReturnQos prq = conSnd.publish(msgUnit);
sentQos[i] = prq;
log.info("Got status='" + prq.getState() + "' rcvTimestamp=" + prq.getRcvTimestamp().toString() +
" for published message '" + prq.getKeyOid() + "'");
}
log.info("============ STEP 3: Stop xmlBlaster");
this.serverThread.stopServer(true);
log.info("============ STEP 4: Start xmlBlaster");
glob.init(Util.getOtherServerPorts(serverPort));
serverThread = EmbeddedXmlBlaster.startXmlBlaster(glob);
log.info("XmlBlaster is ready for testing");
log.info("============ STEP 5: Start subscriber");
// A testsuite helper to collect update messages
this.updateInterceptorRcv = new MsgInterceptor(glob, log, null);
Global globRcv = glob.getClone(null);
conRcv = globRcv.getXmlBlasterAccess();
ConnectQos qosSub = new ConnectQos(globRcv, sessionNameRcv, passwd);
CallbackAddress addr = new CallbackAddress(globRcv);
addr.setRetries(-1);
String secretCbSessionId = "TrustMeSub";
addr.setSecretCbSessionId(secretCbSessionId);
qosSub.getSessionCbQueueProperty().setCallbackAddress(addr);
ConnectReturnQos crqSub = conRcv.connect(qosSub, this.updateInterceptorRcv); // Login to xmlBlaster
log.info("Connect as subscriber '" + crqSub.getSessionName() + "' success");
SubscribeKey sk = new SubscribeKey(globRcv, oid);