ConsumerMessages cm = (ConsumerMessages) repliesIn.get();
canStop = false;
Vector msgs = cm.getMessages();
int sessionMsgCounter = maxMsgs + 1;
ServerSession serverSess = null;
Session sess = null;
for (int i = 0; i < msgs.size(); i++) {
if (sessionMsgCounter > maxMsgs) {
if (serverSess != null)
serverSess.start();
serverSess = sessPool.getServerSession();
// This can hang if there is no more sessions
// in the pool
Object obj = serverSess.getSession();
if (obj instanceof Session) {
sess = (Session) obj;
} else if (obj instanceof XASession) {
sess = ((XASession) obj).sess;
} else {
throw new Error("Unexpected session type: " + obj);
}
sess.setMessageConsumerListener(MultiSessionConsumer.this);
sessionMsgCounter = 1;
}
sess.onMessage((org.objectweb.joram.shared.messages.Message) msgs.get(i));
sessionMsgCounter++;
}
serverSess.start();
repliesIn.pop();
}
} catch (InterruptedException exc) {
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, "", exc);