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.
optsNatsJSConsumeOptsConsume options. (default:
MaxMsgs1,000)cancellationTokenCancellationTokenA CancellationToken used to cancel the call.
Returns
- IAsyncEnumerable<NatsJSMsg<T>>
Async enumerable of messages which can be used in a
await foreachloop.
Type Parameters
TMessage type to deserialize.
Exceptions
- NatsJSProtocolException
Consumer is deleted, it's push based or request sent to server is invalid.