{
int ackMode = state.getAcknowledgeMode();
Object[] args = mi.getArguments();
DeliveryInfo info = (DeliveryInfo)args[0];
if (ackMode == Session.CLIENT_ACKNOWLEDGE)
{
// We collect acknowledgments in the list
if (trace) { log.trace(this + " added to CLIENT_ACKNOWLEDGE list delivery " + info); }
// Sanity check
if (info.getConnectionConsumerSession() != null)
{
throw new IllegalStateException(
"CLIENT_ACKNOWLEDGE cannot be used with a connection consumer");
}
result = state.addToClientAckList(info);
}
// if XA and there is no transaction enlisted on XA we will act as AutoAcknowledge
// However if it's a MDB (if there is a DistinguishedListener) we should behaved as transacted
else if (ackMode == Session.AUTO_ACKNOWLEDGE || isXAAndConsideredNonTransacted(state))
{
// We collect the single acknowledgement in the state.
if (trace) { log.trace(this + " added " + info + " to session state"); }
state.setAutoAckInfo(info);
}
else if (ackMode == Session.DUPS_OK_ACKNOWLEDGE)
{
if (trace) { log.trace(this + " added to DUPS_OK_ACKNOWLEDGE list delivery " + info); }
state.getClientAckList().add(info);
//Also set here - this would be used for recovery in a message listener
state.setAutoAckInfo(info);
}
else
{
Object txID = state.getCurrentTxId();
if (txID != null)
{
// the session is non-XA and transacted, or XA and enrolled in a global transaction. An
// XA session that has not been enrolled in a global transaction behaves as a
// transacted session.
ConnectionState connState = (ConnectionState)state.getParent();
if (trace) { log.trace("sending acknowlegment transactionally, queueing on resource manager"); }
// If the ack is for a delivery that came through via a connection consumer then we use
// the connectionConsumer session as the session id, otherwise we use this sessions'
// session ID
ClientSessionDelegate connectionConsumerDelegate =
(ClientSessionDelegate)info.getConnectionConsumerSession();
String sessionId = connectionConsumerDelegate != null ?
connectionConsumerDelegate.getID() : state.getSessionID();
if (info.getSource() != null)
{
//from a normal session (non CC).
result = state.addAckToResourceManager(connState.getResourceManager(), txID, sessionId, info);
}
else