Creates a lazily-initialized subscription to the specified topic that is also an AsyncIterableIterator.
This allows consuming published messages using the for await ... of
syntax.
If an async iteration completes or ends early (e.g., via break
, return
, or an error),
the subscription is automatically disposed.
The subscription is created lazily: it is only registered when the first call
to next()
or single()
occurs. If iteration never begins, no subscription is created.
Subscribes to the specified topic with a callback.
The subscription is established immediately, and stays active until disposal.
The topic to subscribe to.
A callback invoked on each topic message.
Subscribes once to the specified topic, returning a promise that resolves with the next published message.
The subscription will be automatically disposed after receiving the first message. Useful for awaiting a single message without manually managing the subscription.
Subscribes once to the specified topic with a callback.
The callback is invoked with the next message, after which the subscription is disposed.
The topic to subscribe to.
A callback invoked on the next topic message.
Sets the maximum number of messages to receive for the next subscription.
When the specified limit is reached, the subscription is automatically disposed.
The maximum number of messages to receive.
Sets the priority for the next subscription.
Higher priority (lower number) subscriptions are notified before lower priority
(higher value) ones. The default priority value is 1
.
A priority value, where a lower number means higher priority.
Allows creating customized subscriptions.