state.incrNextTargetMsgSeqNum();
    public synchronized void next(Message message) throws FieldNotFound, RejectLogon,            IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType, IOException,            InvalidMessage {        if (!checkSessionTime()) {            reset();            return;        }        String msgType = message.getHeader().getString(MsgType.FIELD);        try {            String beginString = message.getHeader().getString(BeginString.FIELD);            if (!beginString.equals(sessionID.getBeginString())) {                throw new UnsupportedVersion();            }            if (dataDictionary != null) {                dataDictionary.validate(message);            }            if (msgType.equals(MsgType.LOGON)) {                nextLogon(message);            } else if (msgType.equals(MsgType.HEARTBEAT)) {                nextHeartBeat(message);            } else if (msgType.equals(MsgType.TEST_REQUEST)) {                nextTestRequest(message);            } else if (msgType.equals(MsgType.SEQUENCE_RESET)) {                nextSequenceReset(message);            } else if (msgType.equals(MsgType.LOGOUT)) {                nextLogout(message);            } else if (msgType.equals(MsgType.RESEND_REQUEST)) {                nextResendRequest(message);            } else if (msgType.equals(MsgType.REJECT)) {                nextReject(message);            } else {                if (!verify(message)) {                    return;                }                state.incrNextTargetMsgSeqNum();            }        } catch (FieldException e) {            generateReject(message, e.getSessionRejectReason(), e.getField());        } catch (FieldNotFound e) {            if (sessionID.getBeginString().compareTo(FixVersions.BEGINSTRING_FIX42) >= 0                    && message.isApp()) {                generateBusinessReject(message,                        BusinessRejectReason.CONDITIONALLY_REQUIRED_FIELD_MISSING, e.field);            } else {                generateReject(message, SessionRejectReason.REQUIRED_TAG_MISSING, e.field);                if (msgType.equals(MsgType.LOGON)) {                    getLog().onEvent("Required field missing from logon");                    disconnect();                }            }        } catch (IncorrectDataFormat e) {            generateReject(message, SessionRejectReason.INCORRECT_DATA_FORMAT_FOR_VALUE, e.field);        } catch (IncorrectTagValue e) {            generateReject(message, SessionRejectReason.VALUE_IS_INCORRECT, e.field);        } catch (InvalidMessage e) {            getLog().onEvent("Skipping invalid message: " + e.getMessage());        } catch (RejectLogon e) {            String rejectMessage = e.getMessage() != null ? (": " + e.getMessage()) : "";            getLog().onEvent("Logon rejected" + rejectMessage);            if (e.isLogoutBeforeDisconnect()) {                generateLogout(e.getMessage());            }            disconnect();        } catch (UnsupportedMessageType e) {            if (sessionID.getBeginString().compareTo(FixVersions.BEGINSTRING_FIX42) >= 0) {                generateBusinessReject(message, BusinessRejectReason.UNSUPPORTED_MESSAGE_TYPE, 0);            } else {                generateReject(message, "Unsupported message type");            }        } catch (UnsupportedVersion e) {            if (msgType.equals(MsgType.LOGOUT)) {                nextLogout(message);            } else {                generateLogout("Incorrect BeginString");                state.incrNextTargetMsgSeqNum();                // 1d_InvalidLogonWrongBeginString.def appears to require                // a disconnect although the C++ didn't appear to be doing it.                // ???                disconnect();            }        } catch (IOException e) {            LogUtil.logThrowable(sessionID, "error processing message", e);        }        nextQueued();        if (isLoggedOn()) {            next();        }    }