This content has been marked as final.
Show 2 replies
-
1. Re: SessionAspect::acknowledgeOnClosing
timfox Nov 15, 2006 9:24 AM (in response to timfox)Ok I think I know the answer.
This is to make sure acks are sent if the session closes before the onMessage completes.private void acknowledgeOnClosing(Invocation invocation) throws JMSException { MethodInvocation mi = (MethodInvocation)invocation; SessionState state = getState(invocation); SessionDelegate del = (SessionDelegate)mi.getTargetObject(); // select eligible acknowledgments List acks = new ArrayList(); for(Iterator i = state.getToAck().iterator(); i.hasNext(); ) { AckInfo ack = (AckInfo)i.next(); if (ack.getAckMode() == Session.AUTO_ACKNOWLEDGE || ack.getAckMode() == Session.DUPS_OK_ACKNOWLEDGE) { acks.add(ack); i.remove(); } } if (!acks.isEmpty()) { del.acknowledgeBatch(acks); } }
One thing I don't understand though is why the ackMode is stored on the ackInfo object.
The ackMode should be accessible as an attribute of the session. What am I missing? -
2. Re: SessionAspect::acknowledgeOnClosing
ovidiu.feodorov Nov 15, 2006 11:46 PM (in response to timfox)That was an edge case discovered by one of our users: trying to close the session from within listener's onMessge() would lead to dead lock. Fixing required to be able to send acknowledgments before closing the session.
Maintaining ackMode per acknowledgment instance is unnecessary. I was trying to cater for an use case that will actually never happen. Needs to be refactored at some point:
http://jira.jboss.org/jira/browse/JBMESSAGING-642