Adds a message listener that will be notified of every message published on this message bus, regardless of topic.
Listeners are invoked before any topic-specific subscribers. This allows observing messages even if no subscriber exists or if a subscriber throws an unrecoverable error.
A callback invoked with the topic and message data.
Creates a new child bus linked to this one for hierarchical broadcasting.
Messages with children
broadcast direction will be propagated to it.
Optional
options: Partial<ChildMessageBusOptions>Disposes the message bus, all its child buses, and all active subscriptions.
After disposal, neither this bus nor any child buses can be used for publishing or subscribing.
Publishes a new message without any associated data to the specified topic.
The topic to publish the message to.
Removes a previously added message listener.
The listener to remove.
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: the first call to next()
or single()
triggers the underlying registration. If the consumer never starts an iteration
or never awaits a message, no subscription is created.
Subscribes to the specified topic with a callback.
The subscription is established immediately, and you can call Subscription.dispose to unsubscribe.
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 message. This allows awaiting a single message without manual subscription management.
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.
The message bus API.