Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/natsws/src/mod.ts>JsMsg

WebSocket NATS
Latest
interface JsMsg
import { type JsMsg } from "https://deno.land/x/natsws@v1.29.2/src/mod.ts";

Represents a message stored in JetStream

Properties

redelivered: boolean

True if the message was redelivered

The delivery info for the message

seq: number

The sequence number for the message

headers: MsgHdrs | undefined

Any headers associated with the message

data: Uint8Array

The message's data

subject: string

The subject on which the message was published

Methods

ack(): void

Indicate to the JetStream server that the message was processed successfully.

nak(millis?: number): void

Indicate to the JetStream server that processing of the message failed, and that it should be resent after the spefied number of milliseconds.

working(): void

Indicate to the JetStream server that processing of the message is on going, and that the ack wait timer for the message should be reset preventing a redelivery.

next(subj: string, ro?: Partial<PullOptions>): void

!! this is an experimental feature - and could be removed

next() combines ack() and pull(), requires the subject for a subscription processing to process a message is provided (can be the same) however, because the ability to specify how long to keep the request open can be specified, this functionality doesn't work well with iterators, as an error (408s) are expected and needed to re-trigger a pull in case there was a timeout. In an iterator, the error will close the iterator, requiring a subscription to be reset.

term(reason?: string): void

Indicate to the JetStream server that processing of the message failed and that the message should not be sent to the consumer again.

ackAck(opts?: Partial<{ timeout: number; }>): Promise<boolean>

Indicate to the JetStream server that the message was processed successfully and that the JetStream server should acknowledge back that the acknowledgement was received.

json<T>(): T

Convenience method to parse the message payload as JSON. This method will throw an exception if there's a parsing error;

string(): string

Convenience method to parse the message payload as string. This method may throw an exception if there's a conversion error