Table of Contents

Method RefreshAsync

Namespace
NATS.Client.JetStream
Assembly
NATS.Client.JetStream.dll

RefreshAsync(CancellationToken)

Retrieve the consumer info from the server and update this consumer.

public ValueTask RefreshAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken used to cancel the API call.

Returns

ValueTask

Remarks

Warning: This method issues a $JS.API.CONSUMER.INFO request to the server on every call. Calling it frequently (e.g., in a message-processing loop or on a short timer) can cause significant load on the NATS cluster, lead to API timeouts, and degrade performance for all clients.

For tracking consumer progress (e.g., pending message count, sequence numbers, or delivery attempts), use Metadata on each received message instead. Note that Metadata is nullable and should be checked for null before accessing its properties. When non-null, it provides NumPending, NumDelivered, Sequence, and Timestamp without requiring a server round-trip.

Exceptions

NatsJSException

There was an issue retrieving the response.

NatsJSApiException

Server responded with an error.