Method CreatePushConsumerAsync
CreatePushConsumerAsync(string, NatsJSPushConsumerOpts?, CancellationToken)
Creates a new push consumer that delivers messages to the subject given in DeliverSubject.
public ValueTask<INatsJSPushConsumer> CreatePushConsumerAsync(string stream, NatsJSPushConsumerOpts? opts = null, CancellationToken cancellationToken = default)
Parameters
streamstringName of the stream to create the consumer under.
optsNatsJSPushConsumerOptsPush consumer options.
cancellationTokenCancellationTokenA CancellationToken used to cancel the API call.
Returns
- ValueTask<INatsJSPushConsumer>
The NATS JetStream push consumer object which can be used retrieving data from the stream with ConsumeAsync<T>(INatsDeserialize<T>?, NatsJSConsumeOpts?, CancellationToken).
Remarks
Ephemeral push consumers (no Name or DurableName) are automatically deleted by the server roughly 5 seconds after the delivery subject loses interest. This means the consumer is also removed if ConsumeAsync<T>(INatsDeserialize<T>?, NatsJSConsumeOpts?, CancellationToken) is not started within that window after creation, or if the connection stays disconnected longer than the threshold. Use a durable consumer, a DeliverGroup or a longer InactiveThreshold for consumption that may be delayed.
Exceptions
- NatsJSException
There was an issue retrieving the response, or DeliverSubject is not set.
- NatsJSApiException
Server responded with an error.
- ArgumentException
The
streamname is invalid.- ArgumentNullException
The
streamname isnull.