Method RefreshAsync
RefreshAsync(CancellationToken)
Retrieve the consumer info from the server and update this consumer.
public ValueTask RefreshAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken used to cancel the API call.
Returns
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.