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

Interface for interacting with JetStream data

Properties

views: Views

Accessor for the JetStream materialized views API

apiPrefix: string

Returns the JS API prefix as processed from the JetStream Options

consumers: Consumers

Returns the interface for accessing Consumers. Consumers allow you to process messages stored in a stream. To create a consumer use JetStreamManager.

streams: Streams

Returns the interface for accessing Streams.

Methods

publish(
subj: string,
payload?: Payload,
options?: Partial<JetStreamPublishOptions>,
): Promise<PubAck>

Publishes a message to a stream. If not stream is configured to store the message, the request will fail with ErrorCode.NoResponders error.

deprecated
pull(
stream: string,
consumer: string,
expires?: number,
): Promise<JsMsg>

Retrieves a single message from JetStream

deprecated
fetch(
stream: string,
durable: string,
opts?: Partial<PullOptions>,
): QueuedIterator<JsMsg>

Similar to pull, but able to configure the number of messages, etc. via PullOptions.

deprecated
pullSubscribe(subject: string, opts: ConsumerOptsBuilder | Partial<ConsumerOpts>): Promise<JetStreamPullSubscription>

Creates a pull subscription. A pull subscription relies on the client to request more messages from the server. If the consumer doesn't exist, it will be created matching the consumer options provided.

It is recommended that a consumer be created first using JetStreamManager APIs and then use the bind option to simply attach to the created consumer.

If the filter subject is not specified in the options, the filter will be set to match the specified subject.

It is more efficient than fetch or pull because a single subscription is used between invocations.

deprecated
subscribe(subject: string, opts: ConsumerOptsBuilder | Partial<ConsumerOpts>): Promise<JetStreamSubscription>

Creates a push subscription. The JetStream server feeds messages to this subscription without the client having to request them. The rate at which messages are provided can be tuned by the consumer by specifying ConsumerConfig#rate_limit_bps | ConsumerConfig.rate_limit_bps and/or ConsumerOpts | maxAckPending.

It is recommended that a consumer be created first using JetStreamManager APIs and then use the bind option to simply attach to the created consumer.

If the filter subject is not specified in the options, the filter will be set to match the specified subject.

jetstreamManager(checkAPI?: boolean): Promise<JetStreamManager>

Returns a JetStreamManager that uses the same JetStreamOptions as the current JetStream context

getOptions(): JetStreamOptions