NATS .NET Client  1.1.4
The NATS.io .NET C# Client
NATS.Client.IEncodedConnection Interface Reference
Inheritance diagram for NATS.Client.IEncodedConnection:
NATS.Client.EncodedConnection

Public Member Functions

void Publish (string subject, object obj)
 
void Publish (string subject, string reply, object obj)
 
object Request (string subject, object obj, int timeout)
 
object Request (string subject, object obj)
 
string NewInbox ()
 
IAsyncSubscription SubscribeAsync (string subject, EventHandler< EncodedMessageEventArgs > handler)
 
IAsyncSubscription SubscribeAsync (string subject, string queue, EventHandler< EncodedMessageEventArgs > handler)
 
void Flush (int timeout)
 
void Flush ()
 
void FlushBuffer ()
 
void Close ()
 
bool IsClosed ()
 
bool IsReconnecting ()
 
void ResetStats ()
 
Task DrainAsync ()
 
Task DrainAsync (int timeout)
 
void Drain ()
 
void Drain (int timeout)
 
bool IsDraining ()
 

Properties

Options Opts [get]
 
string ConnectedUrl [get]
 
string ConnectedId [get]
 
string[] Servers [get]
 
string[] DiscoveredServers [get]
 
Exception LastError [get]
 
ConnState State [get]
 
IStatistics Stats [get]
 
long MaxPayload [get]
 
Serializer OnSerialize [get, set]
 
Deserializer OnDeserialize [get, set]
 
int SubscriptionCount [get]
 

Detailed Description

Represents a connection to a NATS Server which uses a client specified encoding scheme.

Member Function Documentation

◆ Close()

void NATS.Client.IEncodedConnection.Close ( )

Closes the IConnection and all associated subscriptions.

See also
IsClosed, State

◆ Drain() [1/2]

void NATS.Client.IEncodedConnection.Drain ( )

Drains a connection for graceful shutdown.

Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the Options.ClosedEventHandler option to know when the connection has moved from draining to closed.

See also
Close()

◆ Drain() [2/2]

void NATS.Client.IEncodedConnection.Drain ( int  timeout)

Drains a connection for graceful shutdown.

Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the Options.ClosedEventHandler option to know when the connection has moved from draining to closed.

See also
Close()
Parameters
timeoutThe duration to wait before draining.


◆ DrainAsync() [1/2]

Task NATS.Client.IEncodedConnection.DrainAsync ( )

Drains a connection for graceful shutdown.

Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the Options.ClosedEventHandler option to know when the connection has moved from draining to closed.

See also
Close()
Returns
A task that represents the asynchronous drain operation.

◆ DrainAsync() [2/2]

Task NATS.Client.IEncodedConnection.DrainAsync ( int  timeout)

Drains a connection for graceful shutdown.

Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connection will be closed. Use the Options.ClosedEventHandler option to know when the connection has moved from draining to closed.

See also
Close()
Parameters
timeoutThe duration to wait before draining.
Returns
A task that represents the asynchronous drain operation.

◆ Flush()

void NATS.Client.IEncodedConnection.Flush ( int  timeout)

Performs a round trip to the server and returns when it receives the internal reply, or throws a NATSTimeoutException exception if the NATS Server does not reply in time.

Parameters
timeoutThe number of milliseconds to wait.

◆ FlushBuffer()

void NATS.Client.IEncodedConnection.FlushBuffer ( )

Immediately flushes the underlying connection buffer if the connection is valid.

Exceptions
NATSConnectionClosedExceptionThe Connection is closed.
NATSExceptionThere was an unexpected exception performing an internal NATS call while executing the request. See Exception.InnerException for more details.

◆ IsClosed()

bool NATS.Client.IEncodedConnection.IsClosed ( )

Returns a value indicating whether or not the IConnection instance is closed.

Returns
true if and only if the IConnection is closed, otherwise false.
See also
Close, State

◆ IsDraining()

bool NATS.Client.IEncodedConnection.IsDraining ( )

Returns a value indicating whether or not the IConnection connection is draining.

Returns
true if and only if the IConnection is closed, otherwise false.
See also
Close, State

◆ IsReconnecting()

bool NATS.Client.IEncodedConnection.IsReconnecting ( )

Returns a value indicating whether or not the IConnection is currently reconnecting.

Returns
true if and only if the IConnection is reconnecting, otherwise false.
See also
State

◆ NewInbox()

string NATS.Client.IEncodedConnection.NewInbox ( )

Creates an inbox string which can be used for directed replies from subscribers.

The returned inboxes are guaranteed to be unique, but can be shared and subscribed to by others.

Returns
A unique inbox string.

◆ Publish() [1/2]

void NATS.Client.IEncodedConnection.Publish ( string  subject,
object  obj 
)

Publishes the serialized value of obj to the given subject .

Parameters
subjectThe subject to publish obj to over the current connection.
objThe Object to serialize and publish to the connected NATS server.
See also
IConnection.Publish(string, byte[])

◆ Publish() [2/2]

void NATS.Client.IEncodedConnection.Publish ( string  subject,
string  reply,
object  obj 
)

Publishes the serialized value of obj to the given subject .

Parameters
subjectThe subject to publish obj to over the current connection.
replyAn optional reply subject.
objThe Object to serialize and publish to the connected NATS server.
See also
IConnection.Publish(string, byte[])

Implemented in NATS.Client.EncodedConnection.

◆ Request() [1/2]

object NATS.Client.IEncodedConnection.Request ( string  subject,
object  obj 
)

Sends a request payload and returns the deserialized response.

Request(string, object) will create an unique inbox for this request, sharing a single subscription for all replies to this IEncodedConnection instance. However, if Options.UseOldRequestStyle is set, each request will have its own underlying subscription. The old behavior is not recommended as it may cause unnecessary overhead on connected NATS servers.

Parameters
subjectThe subject to publish obj to over the current connection.
objThe Object to serialize and publish to the connected NATS server.
Returns
A Object with the deserialized response from the NATS server.
See also
IConnection.Request(string, byte[])

Implemented in NATS.Client.EncodedConnection.

◆ Request() [2/2]

object NATS.Client.IEncodedConnection.Request ( string  subject,
object  obj,
int  timeout 
)

Sends a request payload and returns the deserialized response, or throws NATSTimeoutException if the timeout expires.

Request(string, object, int) will create an unique inbox for this request, sharing a single subscription for all replies to this IEncodedConnection instance. However, if Options.UseOldRequestStyle is set, each request will have its own underlying subscription. The old behavior is not recommended as it may cause unnecessary overhead on connected NATS servers.

Parameters
subjectThe subject to publish obj to over the current connection.
objThe Object to serialize and publish to the connected NATS server.
timeoutThe number of milliseconds to wait.
Returns
A Object with the deserialized response from the NATS server.
See also
IConnection.Request(string, byte[])

Implemented in NATS.Client.EncodedConnection.

◆ ResetStats()

void NATS.Client.IEncodedConnection.ResetStats ( )

Resets the associated statistics for the IConnection.

See also
Stats

◆ SubscribeAsync() [1/2]

IAsyncSubscription NATS.Client.IEncodedConnection.SubscribeAsync ( string  subject,
EventHandler< EncodedMessageEventArgs handler 
)

Expresses interest in the given subject to the NATS Server, and begins delivering messages to the given event handler.

The IAsyncSubscription returned will start delivering messages to the event handler as soon as they are received. The caller does not have to invoke IAsyncSubscription.Start.

Parameters
subjectThe subject on which to listen for messages. The subject can have wildcards (partial: *, full: >).
handlerThe EventHandler<TEventArgs> invoked when messages are received on the returned IAsyncSubscription.
Returns
An IAsyncSubscription to use to read any messages received from the NATS Server on the given subject .
See also
ISubscription.Subject

Implemented in NATS.Client.EncodedConnection.

◆ SubscribeAsync() [2/2]

IAsyncSubscription NATS.Client.IEncodedConnection.SubscribeAsync ( string  subject,
string  queue,
EventHandler< EncodedMessageEventArgs handler 
)

Creates an asynchronous queue subscriber on the given subject , and begins delivering messages to the given event handler.

The IAsyncSubscription returned will start delivering messages to the event handler as soon as they are received. The caller does not have to invoke IAsyncSubscription.Start.

Parameters
subjectThe subject on which to listen for messages. The subject can have wildcards (partial: *, full: >).
queueThe name of the queue group in which to participate.
handlerThe EventHandler<TEventArgs> invoked when messages are received on the returned IAsyncSubscription.
Returns
An IAsyncSubscription to use to read any messages received from the NATS Server on the given subject .
See also
ISubscription.Subject, ISubscription.Queue

Implemented in NATS.Client.EncodedConnection.

Property Documentation

◆ DiscoveredServers

string [] NATS.Client.IEncodedConnection.DiscoveredServers
get

Gets an array of server URLs that were discovered after this instance connected.

If authentication is enabled, Options.User or Options.Token must be used when connecting with these URLs.

◆ MaxPayload

long NATS.Client.IEncodedConnection.MaxPayload
get

Gets the maximum size in bytes of any payload sent to the connected NATS Server.

See also
Publish(string, object), Publish(string, string, object), Request(string, object), Request(string, object, int)

◆ Servers

string [] NATS.Client.IEncodedConnection.Servers
get

Gets an array of known server URLs for this instance.

Servers also includes any additional servers discovered after a connection has been established. If authentication is enabled, Options.User or Options.Token must be used when connecting with these URLs.

◆ State

ConnState NATS.Client.IEncodedConnection.State
get

Gets the current state of the IConnection.

See also
ConnState

◆ Stats

IStatistics NATS.Client.IEncodedConnection.Stats
get

Gets the statistics tracked for the IConnection.

See also
ResetStats

The documentation for this interface was generated from the following file: