[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: SessionAspect::acknowledgeOnClosing

timfox do-not-reply at jboss.com
Wed Nov 15 09:25:00 EST 2006


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986153#3986153

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986153



More information about the jboss-dev-forums mailing list