return null;
}
public Object handlePostDeliver(Invocation invocation) throws Throwable
{
MethodInvocation mi = (MethodInvocation)invocation;
SessionState state = getState(invocation);
int ackMode = state.getAcknowledgeMode();
if (ackMode == Session.AUTO_ACKNOWLEDGE)
{
// We auto acknowledge.
SessionDelegate sd = (SessionDelegate)mi.getTargetObject();
// It is possible that session.recover() is called inside a message listener onMessage
// method - i.e. between the invocations of preDeliver and postDeliver. In this case we
// don't want to acknowledge the last delivered messages - since it will be redelivered.
if (!state.isRecoverCalled())
{
DeliveryInfo delivery = state.getAutoAckInfo();
if (delivery == null)
{
throw new IllegalStateException("Cannot find delivery to AUTO_ACKNOWLEDGE");
}
if (trace) { log.trace(this + " auto acknowledging delivery " + delivery); }
// We clear the state in a finally so then we don't get a knock on
// exception on the next ack since we haven't cleared the state. See
// http://jira.jboss.org/jira/browse/JBMESSAGING-852
//This is ok since the message is acked after delivery, then the client
//could get duplicates anyway
try
{
ackDelivery(sd, delivery);
}
finally
{
state.setAutoAckInfo(null);
}
}
else
{
if (trace) { log.trace(this + " recover called, so NOT acknowledging"); }
state.setRecoverCalled(false);
}
}
else if (ackMode == Session.DUPS_OK_ACKNOWLEDGE)
{
List acks = state.getClientAckList();
if (!state.isRecoverCalled())
{
if (acks.size() >= state.getDupsOKBatchSize())
{
// We clear the state in a finally
// http://jira.jboss.org/jira/browse/JBMESSAGING-852
SessionDelegate sd = (SessionDelegate)mi.getTargetObject();
try
{
sd.acknowledgeDeliveries(acks);
}