Releases the client's connection.
Active consume calls and iterators stop, and events they did not
acknowledge are redelivered later. Close is safe to call more than once.
NotificationError When the connection cannot be closed cleanly.
Consumes events until the signal aborts, the client closes, or the handler returns stopConsuming.
A handler that returns normally acknowledges the event. A handler that throws leaves it unacknowledged, and the server redelivers it after a delay that doubles with each attempt up to 30 seconds. Events are handled one at a time, so a slow handler applies backpressure to the pull.
Cancellation is a normal stop and resolves the promise; it is not an error. A decode failure without an error handler rejects with DecodeError. A permanently lost consumer or connection rejects with NotificationError.
Processes one event at a time.
An optional cancellation signal.
Resolves when consumption stops.
NotificationError When consumption fails.
Iterates events without automatic acknowledgement.
The caller acknowledges each event with ack, nak, or term on the
yielded delivery. Stopping iteration leaves unacknowledged events for
redelivery after the consumer's acknowledgement timeout.
An optional cancellation signal.
An async iterator over the listener's events.
NotificationError When used after close, or when iteration fails.
StaticconnectConnects to the notification tier and resolves the listener's durable consumer.
The initial connection and the consumer lookup fail here rather than on the first event. After a successful connection the transport reconnects indefinitely when the tier is unreachable, and the consumer resumes from its acknowledgement floor.
The URL, listener API key, and listener identifier.
A connected client.
NotificationError When an option is invalid, the server rejects the API key, or the listener's consumer does not exist.
Consumes one listener's mxRaven client notification events over NATS JetStream.
Notifications are off by default. Enable them for the listener with the mxRaven administrative API first; that creates the durable consumer this client reads from.
The connection authenticates with the listener's ordinary API key and only grants access to that listener's consumer, so the key prefix and secret are the same values used for SMTP submission.
A client is safe for concurrent use. A
consumecall and aneventsiterator share the durable consumer with any other client using the same API key: events are distributed between them, not duplicated to each.Example