2 Replies Latest reply on Nov 15, 2006 11:46 PM by Ovidiu Feodorov


    Tim Fox Master

      This method was added some time ago and seems a bit fishy to me.

      Can someone remind me why we need it?


        • 1. Re: SessionAspect::acknowledgeOnClosing
          Tim Fox Master

          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)
           if (!acks.isEmpty())

          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 Master

            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: