Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Latest
interface ConsumerOptsBuilder
import { type ConsumerOptsBuilder } from "https://deno.land/x/natsws@v1.28.0/src/mod.ts";

A builder API that creates a ConsumerOpt

Methods

description(description: string): this

User description of this consumer

deliverTo(subject: string): this

DeliverTo sets the subject where a push consumer receives messages

durable(name: string): this

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

startSequence(seq: number): this

The consumer will start at the message with the specified sequence

startTime(time: Date): this

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

deliverAll(): this

Consumer will start at first available message on the stream

deliverLastPerSubject(): this

Consumer will deliver all the last per messages per subject

deliverLast(): this

Consumer will start at the last message

deliverNew(): this

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

startAtTimeDelta(millis: number): this

Start delivering at the at a past point in time

headersOnly(): 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.

ackNone(): this

Consumer will not track ack for messages

ackAll(): this

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

ackExplicit(): 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.

ackWait(millis: number): this

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

maxDeliver(max: number): this

Max number of re-delivery attempts for a particular message

filterSubject(s: string): this

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

replayInstantly(): this

Replay messages as fast as possible

replayOriginal(): this

Replay at the rate received

sample(n: number): this

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

limit(bps: number): this

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

maxWaiting(max: number): this

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

maxAckPending(max: number): this

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

idleHeartbeat(millis: number): 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.

flowControl(): 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.

deliverGroup(name: string): this

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

manualAck(): this

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

maxMessages(max: number): 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.

queue(n: string): this

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

callback(fn: JsMsgCallback): this

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

orderedConsumer(): 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.

bind(stream: string, durable: string): 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.

bindStream(stream: string): this

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

maxPullBatch(n: number): 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.

maxPullRequestExpires(millis: number): 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.

inactiveEphemeralThreshold(millis: number): 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.

memory(): this

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

numReplicas(n: number): this

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

consumerName(n: string): this

The name of the consumer