long subjMaxEntriesCache = 2;
long exLimit = cbMaxEntries + subjMaxEntries + 2;
this.destination = new PtPDestination(this.glob, "joe/1");
/** wants PtP messages and does not shutdown */
boolean wantsPtP = true;
boolean shutdownCB = false;
try {
this.destination.init(wantsPtP, shutdownCB, cbMaxEntries, cbMaxEntriesCache, subjMaxEntries, subjMaxEntriesCache);
}
catch (XmlBlasterException ex) {
assertTrue("an exception while initing the destination should not occur " + ex.getMessage(), false);
}
for (int i=0; i < exLimit; i++) {
try {
doPublish(i, oid, doGc, PUB_DELAY);
}
catch (Exception ex) {
assertTrue("an exception on publish '" + i + "' should not occur " + ex.getMessage(), false);
}
}
int ret = this.destination.getUpdateInterceptor().waitOnUpdate(3000L*exLimit, (int)exLimit);
assertEquals("wrong number of entries arrived", (int)exLimit, ret);
// wait half a second more to see if more messages come
ret = this.destination.getUpdateInterceptor().waitOnUpdate(500L, (int)exLimit+1);
assertEquals("wrong number of entries arrived", (int)exLimit, ret);
Msg[] msg = this.destination.getUpdateInterceptor().getMsgs();
assertEquals("wrong number of messages", exLimit, msg.length);
for (int i=0; i < exLimit; i++) {
assertEquals("wrong message sequence at ", i, msg[i].getContentInt());
}
this.destination.getUpdateInterceptor().clear();
// now stop the receiver by shutting down its cbServer and fill cbQueue and subjQueue
this.destination.getConnection().leaveServer(null);
for (long i=exLimit; i < 2 * exLimit; i++) {
try {
doPublish((int)i, oid, doGc, PUB_DELAY);
}
catch (XmlBlasterException ex) {
assertTrue("an exception on publish '" + i + "' should not occur " + ex.getMessage(), false);
}
}
this.destination.check(250L, 0);
for (long i=2*exLimit; i < 2*exLimit + 2; i++) {
try {
doPublish((int)i, oid, doGc, PUB_DELAY);
assertTrue("an exception on publish '" + i + "' should have occurred ", false);
}
catch (XmlBlasterException ex) {
log.info("this is an allowed exception since queues are overflown");
}
}
this.destination.check(250L, 0);
// stop and restart the server
EmbeddedXmlBlaster.stopXmlBlaster(this.serverThread);
this.serverThread = EmbeddedXmlBlaster.startXmlBlaster(Util.getOtherServerPorts(this.serverPort));
// reconnect to server (for the destination, the publisher never left)
this.destination = new PtPDestination(this.glob, "joe/1");
/** wants PtP messages and does not shutdown */
try {
// we pass -1 -1 for the subject queue to avoid reconviguration
// otherwise it will shut down the callback