Table of Contents

Method CreateConsumerAsync

Namespace
NATS.Client.JetStream
Assembly
NATS.Client.JetStream.dll

CreateConsumerAsync(string, ConsumerConfig, CancellationToken)

Creates new consumer if it doesn't exists.

public ValueTask<INatsJSConsumer> CreateConsumerAsync(string stream, ConsumerConfig config, CancellationToken cancellationToken = default)

Parameters

stream string

Name of the stream to create consumer under.

config ConsumerConfig

Consumer configuration.

cancellationToken CancellationToken

A CancellationToken used to cancel the API call.

Returns

ValueTask<INatsJSConsumer>

The NATS JetStream consumer object which can be used retrieving data from the stream.

Exceptions

NatsJSException

Ack policy is set to none or there was an issue retrieving the response.

NatsJSApiException

Server responded with an error.

ArgumentException

The stream name is invalid.

ArgumentNullException

The stream name is null.