{
int iterations = numMessages / ackSize;
for (int outerCount = 0; outerCount < iterations; outerCount++)
{
Message m = null;
for (int innerCount = 0; innerCount < ackSize; innerCount++)
{
m = getMessage();
if (m == null)
{
log.error("Message is null");
failed = true;
return;
}
String prodName = m.getStringProperty("PROD_NAME");
Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
// log.info("got " + prodName + ":" + msgCount);
Count count = (Count)counts.get(prodName);
if (count == null)
{
//First time
if (msgCount.intValue() != 0)
{
log.error("First message from " + prodName + " is not 0, it is " + msgCount);
failed = true;
return;
}
else
{
count = new Count();
counts.put(prodName, count);
}
}
else
{
if (count.lastAcked != msgCount.intValue() - 1)
{
log.error("Message out of sequence for " + prodName + ", expected " + (count.lastAcked + 1));
failed = true;
return;
}
}
count.lastAcked = msgCount.intValue();
count.lastReceived = msgCount.intValue();
if (innerCount == ackSize -1)
{
m.acknowledge();
}
this.processingDone();
}
if (outerCount == iterations - 1)
{
break;
}
for (int innerCount = 0; innerCount < recoverSize; innerCount++)
{
m = getMessage();
if (m == null)
{
log.error("Message is null");
return;
}
String prodName = m.getStringProperty("PROD_NAME");
Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
// log.info("got " + prodName + ":" + msgCount);
Count count = (Count)counts.get(prodName);
if (count == null)
{