for (int i=0; i < ids.length; i ++) {
if (DEBUG) {
logger.log(logger.INFO, "handleAcks["+i+", "+ids.length+"]:sysid="+
ids[i]+", cid="+cids[i]+", on connection "+con);
}
Session s = Session.getSession(cids[i]);
if (s == null) { // consumer does not have session
Consumer c = Consumer.getConsumer(cids[i]);
if (c == null) {
if (!con.isValid() || con.isBeingDestroyed()) {
logger.log(logger.DEBUG,"Received ack for consumer "
+ cids[i] + " on closing connection " + con);
continue;
}
if (BrokerStateHandler.shutdownStarted)
throw new BrokerException(
BrokerResources.I_ACK_FAILED_BROKER_SHUTDOWN);
throw new BrokerException("Internal Error: Unable to complete processing acks:"
+ " Unknown consumer " + cids[i]);
} else if (c.getConsumerUID().getBrokerAddress() !=
Globals.getClusterBroadcast().getMyAddress())
{
// remote consumer
PacketReference ref = Destination.get(ids[i]);
ConsumerUID cuid = c.getConsumerUID();
// right now we dont store messages for remote
// brokers so the sync flag is unnecessary
// but who knows if that will change
if (ref.acknowledged(cuid, c.getStoredConsumerUID(),
!cuid.isDupsOK(), true, ackack)) {
l.add(ref);
}
} else {
logger.log(Logger.INFO,
Globals.getBrokerResources().getString(
BrokerResources.E_INTERNAL_BROKER_ERROR,
"local consumer does not have "
+ "associated session " + c));
throw new BrokerException("Unknown local consumer "
+ cids[i]);
}
} else { // we have a session
if (fi.FAULT_INJECTION) {
PacketReference ref = Destination.get(ids[i]);
if (ref != null && !ref.getDestination().isAdmin() && !ref.getDestination().isInternal()) {
if (fi.checkFault(fi.FAULT_ACK_MSG_1_5, null)) {
fi.unsetFault(fi.FAULT_ACK_MSG_1_5);
BrokerException bex = new BrokerException("FAULT:"+fi.FAULT_ACK_MSG_1_5, Status.GONE);
bex.setRemoteConsumerUIDs(String.valueOf(cids[i].longValue()));
bex.setRemote(true);
throw bex;
}
}
}
PacketReference ref = s.ackMessage(cids[i], ids[i], ackack);
if (ref != null) {
l.add(ref);
}
}
}