Table of Contents

Class NatsConnection

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll
public class NatsConnection : INatsConnection, IAsyncDisposable
Inheritance
NatsConnection
Implements
Inherited Members
Extension Methods

Constructors

NatsConnection()
NatsConnection(NatsOpts)

Fields

OnConnectingAsync

Hook before TCP connection open.

Properties

ConnectionState
Opts
ServerInfo

Methods

ConnectAsync()

Connect socket and write CONNECT command to nats server.

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

NewInbox()

Create a new inbox subject with the form {Inbox Prefix}.{Unique Connection ID}.{Unique Inbox ID}

PingAsync(CancellationToken)

Send PING command and await PONG. Return value is similar as Round Trip Time (RTT).

PublishAsync(string, NatsHeaders?, string?, NatsPubOpts?, CancellationToken)

Publishes an empty message payload to the given subject name, optionally supplying a reply subject.

PublishAsync<T>(in NatsMsg<T>, INatsSerialize<T>?, NatsPubOpts?, CancellationToken)

Publishes a serializable message payload to the given subject name, optionally supplying a reply subject.

PublishAsync<T>(string, T?, NatsHeaders?, string?, INatsSerialize<T>?, NatsPubOpts?, CancellationToken)

Publishes a serializable message payload to the given subject name, optionally supplying a reply subject.

RequestAsync<TRequest, TReply>(string, TRequest?, NatsHeaders?, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)

Request and receive a single reply from a responder.

RequestManyAsync<TRequest, TReply>(string, TRequest?, NatsHeaders?, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)

Request and receive zero or more replies from a responder.

SubscribeAsync<T>(string, string?, INatsDeserialize<T>?, NatsSubOpts?, CancellationToken)

Initiates a subscription to a subject, optionally joining a distributed queue group.

SubscribeCoreAsync<T>(string, string?, INatsDeserialize<T>?, NatsSubOpts?, CancellationToken)

Initiates a subscription to a subject, optionally joining a distributed queue group and returns a INatsSub<T> object which provides more control over the subscription.

Events

ConnectionDisconnected
ConnectionOpened
MessageDropped
ReconnectFailed