Method ConsumeAsync
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
NatsJSConsumeOptsConsume options.
cancellationToken
CancellationTokenA 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.