Search in sources :

Example 1 with StompUnrecoverableAckException

use of com.sun.messaging.bridge.api.StompUnrecoverableAckException in project openmq by eclipse-ee4j.

the class StompSubscriberSession method ack.

public void ack(String msgid) throws Exception {
    if (_session.getAcknowledgeMode() != Session.CLIENT_ACKNOWLEDGE) {
        throw new JMSException(_sbr.getKString(_sbr.X_NOT_CLIENT_ACK_MODE, msgid, _subid));
    }
    synchronized (_unacked) {
        Message msg = null;
        int end = _unacked.size() - 1;
        boolean found = false;
        int i = 0;
        for (i = end; i >= 0; i--) {
            msg = _unacked.get(i);
            if (msgid.equals(msg.getJMSMessageID())) {
                try {
                    if (!_clientack_thismsg) {
                        ((com.sun.messaging.jmq.jmsclient.MessageImpl) msg).acknowledgeUpThroughThisMessage();
                    } else {
                        ((com.sun.messaging.jmq.jmsclient.MessageImpl) msg).acknowledgeThisMessage();
                        _unacked.remove(i);
                        break;
                    }
                    _ackfailureCount = 0;
                } catch (Exception e) {
                    _ackfailureCount++;
                    Exception ex = null;
                    if ((e instanceof JMSException) && (_session instanceof com.sun.messaging.jmq.jmsclient.SessionImpl) && ((com.sun.messaging.jmq.jmsclient.SessionImpl) _session)._appCheckRemoteException((JMSException) e)) {
                        ex = new StompUnrecoverableAckException("An unrecoverable ACK failure has occurred in subscriber " + this, e);
                        throw ex;
                    }
                    if (_ackfailureCount > MAX_CONSECUTIVE_ACK_FAILURES) {
                        ex = new StompUnrecoverableAckException("Maximum consecutive ACK failures " + MAX_CONSECUTIVE_ACK_FAILURES + " has occurred in subscriber " + this, e);
                        throw ex;
                    }
                    throw e;
                }
                found = true;
                break;
            }
        }
        if (found && !_clientack_thismsg) {
            for (int j = 0; j <= i; j++) {
                _unacked.remove(0);
            }
            return;
        }
    }
    throw new JMSException(_sbr.getKString(_sbr.X_ACK_MSG_NOT_FOUND_IN_SUB, msgid, _subid));
}
Also used : StompMessage(com.sun.messaging.bridge.api.StompMessage) StompFrameMessage(com.sun.messaging.bridge.api.StompFrameMessage) StompUnrecoverableAckException(com.sun.messaging.bridge.api.StompUnrecoverableAckException) StompUnrecoverableAckException(com.sun.messaging.bridge.api.StompUnrecoverableAckException) StompProtocolException(com.sun.messaging.bridge.api.StompProtocolException)

Aggregations

StompFrameMessage (com.sun.messaging.bridge.api.StompFrameMessage)1 StompMessage (com.sun.messaging.bridge.api.StompMessage)1 StompProtocolException (com.sun.messaging.bridge.api.StompProtocolException)1 StompUnrecoverableAckException (com.sun.messaging.bridge.api.StompUnrecoverableAckException)1