if (status == ExchangeStatus.ACTIVE) { this.state = this.states[this.state][STATES_NEXT_MSG];
if (status == ExchangeStatus.ACTIVE && packet.getFault() == null) { this.state = this.states[this.state][STATES_NEXT_OUT]; } else if (status == ExchangeStatus.ACTIVE && packet.getFault() != null) { this.state = this.states[this.state][STATES_NEXT_FAULT];
    public void handleSend(boolean sync) throws MessagingException {        // Check if send / sendSync is legal        if (sync) {            if (!can(CAN_SEND_SYNC)) {                throw new MessagingException("illegal call to sendSync");            }        } else {            if (!can(CAN_SEND)) {                throw new MessagingException("illegal call to send");            }        }        this.syncState = sync ? SYNC_STATE_SYNC_SENT : SYNC_STATE_ASYNC;        // Check status        ExchangeStatus status = getStatus();        if (status == ExchangeStatus.ACTIVE && !can(CAN_STATUS_ACTIVE)) {            throw new MessagingException("illegal exchange status: active");        }        if (status == ExchangeStatus.DONE && !can(CAN_STATUS_DONE)) {            throw new MessagingException("illegal exchange status: done");        }        if (status == ExchangeStatus.ERROR && !can(CAN_STATUS_ERROR)) {            throw new MessagingException("illegal exchange status: error");        }        // Check message        // Change state        if (status == ExchangeStatus.ACTIVE) {            this.state = this.states[this.state][STATES_NEXT_MSG];        } else if (status == ExchangeStatus.ERROR) {            this.state = this.states[this.state][STATES_NEXT_ERROR];        } else if (status == ExchangeStatus.DONE) {            this.state = this.states[this.state][STATES_NEXT_DONE];        } else {            throw new IllegalStateException("unknown status");        }        if (this.state < 0 || this.state >= this.states.length) {            throw new IllegalStateException("next state is illegal");        }    }