Search in sources :

Example 1 with JetStreamStatusException

use of io.nats.client.JetStreamStatusException in project nats.java by nats-io.

the class PushStatusMessageManager method manage.

boolean manage(Message msg) {
    if (msg.isStatusMessage()) {
        // this checks fc, hb and unknown
        // only process fc and hb if those flags are set
        // otherwise they are simply known statuses
        Status status = msg.getStatus();
        if (status.isFlowControl()) {
            if (fc) {
                _processFlowControl(msg.getReplyTo(), ErrorListener.FlowControlSource.FLOW_CONTROL);
            }
            return true;
        }
        if (status.isHeartbeat()) {
            if (fc) {
                // status flowControlSubject is set in the beforeQueueProcessor
                _processFlowControl(extractFcSubject(msg), ErrorListener.FlowControlSource.HEARTBEAT);
            }
            return true;
        }
        // this status is unknown to us, always use the error handler.
        // If it's a sync call, also throw an exception
        conn.getOptions().getErrorListener().unhandledStatus(conn, sub, status);
        if (syncMode) {
            throw new JetStreamStatusException(sub, status);
        }
        return true;
    }
    // JS Message
    lastStreamSeq = msg.metaData().streamSequence();
    lastConsumerSeq = msg.metaData().consumerSequence();
    return false;
}
Also used : Status(io.nats.client.support.Status) JetStreamStatusException(io.nats.client.JetStreamStatusException)

Aggregations

JetStreamStatusException (io.nats.client.JetStreamStatusException)1 Status (io.nats.client.support.Status)1