Table of Contents

Method ConsumeAsync

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

ConsumeAsync<T>(INatsDeserialize<T>?, NatsJSConsumeOpts?, CancellationToken)

Consume messages from the stream in order.

public IAsyncEnumerable<NatsJSMsg<T>> ConsumeAsync<T>(INatsDeserialize<T>? serializer = null, NatsJSConsumeOpts? opts = null, CancellationToken cancellationToken = default)

Parameters

serializer INatsDeserialize<T>

Serializer to use for the message type.

opts NatsJSConsumeOpts

Consume options.

cancellationToken CancellationToken

A CancellationToken used to cancel consume operation.

Returns

IAsyncEnumerable<NatsJSMsg<T>>

Asynchronous enumeration which can be used in a await foreach loop.

Type Parameters

T

Serialized message data type.

Exceptions

NatsJSProtocolException

There was a JetStream server error.