Method ConsumeAsync
ConsumeAsync<T>(INatsDeserialize<T>?, NatsJSConsumeOpts?, CancellationToken)
Starts consuming messages from the ordered push consumer.
public IAsyncEnumerable<INatsJSMsg<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. Only NotificationHandler is applicable: it receives NatsJSTimeoutNotification when no messages or heartbeats arrive within twice the idle heartbeat interval (default 5 seconds, i.e. 10 seconds of silence), at which point the underlying consumer is recreated automatically. The remaining options (e.g.
MaxMsgs,Expires,IdleHeartbeat,ThresholdMsgs,ThresholdBytes) control pull-consumer behavior and are not applicable to ordered push consumers.cancellationTokenCancellationTokenA CancellationToken used to cancel consume operations.
Returns
- IAsyncEnumerable<INatsJSMsg<T>>
An asynchronous enumerable of messages.
Type Parameters
TMessage type to deserialize.
Exceptions
- NatsJSProtocolException
Consumer is deleted, it's push based or request sent to server is invalid.