{
if (trace) { log.trace(this + " processing transaction " + tx); }
for (Iterator i = txState.getSessionStates().iterator(); i.hasNext(); )
{
SessionTxState sessionState = (SessionTxState)i.next();
// send the messages
for (Iterator j = sessionState.getMsgs().iterator(); j.hasNext(); )
{
JBossMessage message = (JBossMessage)j.next();
if (checkForDuplicates && !message.isReliable())
{
//Ignore np messages on failover
}
else
{
boolean accepted = sendMessage(message, tx, checkForDuplicates);
if (!accepted)
{
break;
}
}
}
// send the acks
// We need to lookup the session in a global map maintained on the server peer. We can't
// just assume it's one of the sessions in the connection. This is because in the case
// of a connection consumer, the message might be delivered through one connection and
// the transaction committed/rolledback through another. ConnectionConsumers suck.
ServerSessionEndpoint session = serverPeer.getSession(sessionState.getSessionId());
if (session == null)
{
throw new IllegalStateException("Cannot find session with id " +
sessionState.getSessionId());
}
session.acknowledgeTransactionally(sessionState.getAcks(), tx);
}
if (trace) { log.trace(this + " processed transaction " + tx); }
}