Interface ConsumerOptsBuilder

A builder API that creates a ConsumerOpt

interface ConsumerOptsBuilder {
    ackAll(): this;
    ackExplicit(): this;
    ackNone(): this;
    ackWait(millis): this;
    bind(stream, durable): this;
    bindStream(stream): this;
    callback(fn): this;
    consumerName(n): this;
    deliverAll(): this;
    deliverGroup(name): this;
    deliverLast(): this;
    deliverLastPerSubject(): this;
    deliverNew(): this;
    deliverTo(subject): this;
    description(description): this;
    durable(name): this;
    filterSubject(s): this;
    flowControl(): this;
    headersOnly(): this;
    idleHeartbeat(millis): this;
    inactiveEphemeralThreshold(millis): this;
    limit(bps): this;
    manualAck(): this;
    maxAckPending(max): this;
    maxDeliver(max): this;
    maxMessages(max): this;
    maxPullBatch(n): this;
    maxPullRequestExpires(millis): this;
    maxWaiting(max): this;
    memory(): this;
    numReplicas(n): this;
    orderedConsumer(): this;
    queue(n): this;
    replayInstantly(): this;
    replayOriginal(): this;
    sample(n): this;
    startAtTimeDelta(millis): this;
    startSequence(seq): this;
    startTime(time): this;
}

Methods

  • Ack'ing a message implicitly acks all messages with a lower sequence

    Returns this

  • Consumer will ack all messages - not that unless manualAck is set the client will auto ack messages after processing via its callback or when the iterator continues processing.

    Returns this

  • Consumer will not track ack for messages

    Returns this

  • Sets the time a delivered message might remain unacknowledged before a redelivery is attempted

    Parameters

    • millis: number

    Returns this

  • Bind to the specified durable (or consumer name if ephemeral) on the specified stream. If the consumer doesn't exist, the subscribe will fail. Bind the recommended way of subscribing to a stream, as it requires the consumer to exist already.

    Parameters

    • stream: string
    • durable: string

    Returns this

  • Specify the name of the stream, avoiding a lookup where the stream is located by searching for a subject.

    Parameters

    • stream: string

    Returns this

  • Use a callback to process messages. If not specified, you process messages by iterating on the returned subscription object.

    Parameters

    Returns this

  • The name of the consumer

    Parameters

    • n: string

    Returns this

  • Consumer will start at first available message on the stream

    Returns this

  • Push consumer only option - Sets the name of the queue group - same as queue

    Parameters

    • name: string

    Returns this

  • Consumer will start at the last message

    Returns this

  • Consumer will deliver all the last per messages per subject

    Returns this

  • Consumer will start with new messages (not yet in the stream)

    Returns this

  • DeliverTo sets the subject where a push consumer receives messages

    Parameters

    • subject: string

    Returns this

  • User description of this consumer

    Parameters

    • description: string

    Returns this

  • Sets the durable name, when not set an ephemeral consumer is created

    Parameters

    • name: string

    Returns this

  • Consumer should filter the messages to those that match the specified filter. This api can be called multiple times.

    Parameters

    • s: string

    Returns this

  • Push consumer flow control - the server sends a status code 100 and uses the delay on the response to throttle inbound messages for a client and prevent slow consumer.

    Returns this

  • Messages delivered to the consumer will not have a payload. Instead, they will have the header Nats-Msg-Size indicating the number of bytes in the message as stored by JetStream.

    Returns this

  • Push consumer only option - Enables idle heartbeats from the server. If the number of specified millis is reached and no messages are available on the server, the server will send a heartbeat (status code 100 message) indicating that the JetStream consumer is alive.

    Parameters

    • millis: number

    Returns this

  • Pull consumer only - Sets the max amount of time that an ephemeral consumer will be allowed to live on the server. If the client doesn't perform any requests during the specified interval the server will discard the consumer.

    Parameters

    • millis: number

    Returns this

  • Limit message delivery to the specified rate in bits per second.

    Parameters

    • bps: number

    Returns this

  • Prevents the consumer implementation from auto-acking messages. Message callbacks and iterators must explicitly ack messages.

    Returns this

  • Max number of outstanding acks before the server stops sending new messages

    Parameters

    • max: number

    Returns this

  • Max number of re-delivery attempts for a particular message

    Parameters

    • max: number

    Returns this

  • Standard NATS subscription option which automatically closes the subscription after the specified number of messages (actual stream or flow control) are seen by the client.

    Parameters

    • max: number

    Returns this

  • Pull consumer only - Sets the max number of messages that can be pulled in a batch that can be requested by a client during a pull.

    Parameters

    • n: number

    Returns this

  • Pull consumer only - Sets the max amount of time before a pull request expires that may be requested by a client during a pull.

    Parameters

    • millis: number

    Returns this

  • Pull subscriber option only. Limits the maximum outstanding messages scheduled via batch pulls as pulls are additive.

    Parameters

    • max: number

    Returns this

  • Force the consumer state to be kept in memory rather than inherit the setting from the Stream

    Returns this

  • When set do not inherit the replica count from the stream but specifically set it to this amount

    Parameters

    • n: number

    Returns this

  • Push consumer only - creates an ordered consumer - ordered consumers cannot be a pull consumer nor specify durable, deliverTo, specify an ack policy, maxDeliver, or flow control.

    Returns this

  • Push consumer only option - Standard NATS queue group option, same as deliverGroup

    Parameters

    • n: string

    Returns this

  • Replay messages as fast as possible

    Returns this

  • Replay at the rate received

    Returns this

  • Sample a subset of messages expressed as a percentage(0-100)

    Parameters

    • n: number

    Returns this

  • Start delivering at the at a past point in time

    Parameters

    • millis: number

    Returns this

  • The consumer will start at the message with the specified sequence

    Parameters

    • seq: number

    Returns this

  • consumer will start with messages received on the specified time/date

    Parameters

    • time: Date

    Returns this