Initiates a drain on the connection and returns a promise that resolves when the drain completes and the connection closes.
Drain is an ordered shutdown of the client. Instead of abruptly closing the client, subscriptions are drained, that is messages not yet processed by a subscription are handled before the subscription is closed. After subscriptions are drained it is not possible to create a new subscription. Then all pending outbound messages are sent to the server. Finally, the connection is closed.
Publishes the specified data to the specified subject.
Optional
payload: PayloadOptional
options: PublishOptionsPublishes using the subject of the specified message, specifying the data, headers and reply found in the message if any.
Use of this API is experimental, and it is subject to be removed.
reconnect() enables a client to force a reconnect. A reconnect will disconnect the client, and possibly initiate a reconnect to the cluster. Note that all reconnect caveats apply:
If the reconnection policy given to the client doesn't allow reconnects, the connection will close.
Messages that are inbound or outbound could be lost.
All requests that are in flight will be rejected.
Note that the returned promise will reject if the client is already closed, or if it is in the process of draining. If the client is currently disconnected, this API has no effect, as the client is already attempting to reconnect.
Publishes a request with specified data in the specified subject expecting a response before RequestOptions#timeout milliseconds. The api returns a Promise that resolves when the first response to the request is received. If there are no responders (a subscription) listening on the request subject, the request will fail as soon as the server processes it.
Optional
payload: PayloadOptional
opts: RequestOptionsPublishes a request expecting multiple responses back. Several strategies to determine when the request should stop gathering responses.
Optional
payload: PayloadOptional
opts: Partial<RequestManyOptions>Replies using the reply subject of the specified message, specifying the data, headers in the message if any.
the number of milliseconds it took for a flush.
Subscribe expresses interest in the specified subject. The subject may have wildcards. Messages are delivered to the SubscriptionOptions callback if specified. Otherwise, the subscription is an async iterator for Msg.
Optional
opts: SubscriptionOptions
ServerInfo to the currently connected server or undefined