Class NatsClient
Represents a NATS client that provides methods for interacting with NATS server.
public class NatsClient : INatsClient, IAsyncDisposable
- Inheritance
-
NatsClient
- Implements
- Inherited Members
- Extension Methods
Constructors
- NatsClient(NatsOpts, BoundedChannelFullMode)
Initializes a new instance of the NatsClient class.
- NatsClient(string, string, string?)
Initializes a new instance of the NatsClient class.
Properties
- Connection
Represents a connection to the NATS server.
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.
- 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>(string, T, NatsHeaders?, string?, INatsSerialize<T>?, NatsPubOpts?, CancellationToken)
Publishes a serializable message payload to the given subject name, optionally supplying a reply subject.
- RequestAsync<TReply>(string, INatsDeserialize<TReply>?, NatsSubOpts?, CancellationToken)
Send an empty request message and await the reply message asynchronously.
- RequestAsync<TRequest, TReply>(string, TRequest?, NatsHeaders?, INatsSerialize<TRequest>?, INatsDeserialize<TReply>?, NatsPubOpts?, NatsSubOpts?, CancellationToken)
Request and receive a single reply from a responder.
- SubscribeAsync<T>(string, string?, INatsDeserialize<T>?, NatsSubOpts?, CancellationToken)
Initiates a subscription to a subject, optionally joining a distributed queue group.