Method ConsumeAsync
ConsumeAsync<T>(INatsDeserialize<T>?, NatsJSConsumeOpts?, CancellationToken)
Starts an enumerator consuming messages from the stream using this consumer.
IAsyncEnumerable<NatsJSMsg<T>> ConsumeAsync<T>(INatsDeserialize<T>? serializer = null, NatsJSConsumeOpts? opts = null, CancellationToken cancellationToken = default)Parameters
- serializerINatsDeserialize<T>
- Serializer to use for the message type. 
- optsNatsJSConsumeOpts
- Consume options. (default: - MaxMsgs1,000)
- cancellationTokenCancellationToken
- A CancellationToken used to cancel the call. 
Returns
- IAsyncEnumerable<NatsJSMsg<T>>
- Async enumerable of messages which can be used in a - await foreachloop.
Type Parameters
- T
- Message type to deserialize. 
Exceptions
- NatsJSProtocolException
- Consumer is deleted, it's push based or request sent to server is invalid.