method NatsBroker.prototype.subscribe
Since 0.1.0
NatsBroker.prototype.subscribe<T>(
topic: string,
handler: MessageHandler<T>,
): Promise<ISubscription>

Subscribes to a topic using JetStream durable consumers.

Type Parameters

The message payload type

Parameters

topic: string

The subject to subscribe to

The handler to invoke for each message

optional
options: SubscribeOptions

Optional subscription options (queue for durable consumer name)

Return Type

Promise<ISubscription>

The subscription handle

Usage

import { NatsBroker } from "messaging-plugin/src/index.ts";