NATS .NET Client
1.1.4
The NATS.io .NET C# Client
|
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] |
Represents a connection to a NATS Server which uses a client specified encoding scheme.
void NATS.Client.IEncodedConnection.Close | ( | ) |
Closes the IConnection and all associated subscriptions.
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.
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.
timeout | The duration to wait before draining. |
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.
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.
timeout | The duration to wait before draining. |
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.
timeout | The number of milliseconds to wait. |
void NATS.Client.IEncodedConnection.FlushBuffer | ( | ) |
Immediately flushes the underlying connection buffer if the connection is valid.
NATSConnectionClosedException | The Connection is closed. |
NATSException | There was an unexpected exception performing an internal NATS call while executing the request. See Exception.InnerException for more details. |
bool NATS.Client.IEncodedConnection.IsClosed | ( | ) |
Returns a value indicating whether or not the IConnection instance is closed.
true
if and only if the IConnection is closed, otherwise false
.bool NATS.Client.IEncodedConnection.IsDraining | ( | ) |
Returns a value indicating whether or not the IConnection connection is draining.
true
if and only if the IConnection is closed, otherwise false
.bool NATS.Client.IEncodedConnection.IsReconnecting | ( | ) |
Returns a value indicating whether or not the IConnection is currently reconnecting.
true
if and only if the IConnection is reconnecting, otherwise false
.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.
void NATS.Client.IEncodedConnection.Publish | ( | string | subject, |
object | obj | ||
) |
Publishes the serialized value of obj to the given subject .
subject | The subject to publish obj to over the current connection. |
obj | The Object to serialize and publish to the connected NATS server. |
void NATS.Client.IEncodedConnection.Publish | ( | string | subject, |
string | reply, | ||
object | obj | ||
) |
Publishes the serialized value of obj to the given subject .
subject | The subject to publish obj to over the current connection. |
reply | An optional reply subject. |
obj | The Object to serialize and publish to the connected NATS server. |
Implemented in NATS.Client.EncodedConnection.
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.
subject | The subject to publish obj to over the current connection. |
obj | The Object to serialize and publish to the connected NATS server. |
Implemented in NATS.Client.EncodedConnection.
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.
subject | The subject to publish obj to over the current connection. |
obj | The Object to serialize and publish to the connected NATS server. |
timeout | The number of milliseconds to wait. |
Implemented in NATS.Client.EncodedConnection.
void NATS.Client.IEncodedConnection.ResetStats | ( | ) |
Resets the associated statistics for the IConnection.
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.
subject | The subject on which to listen for messages. The subject can have wildcards (partial: * , full: > ). |
handler | The EventHandler<TEventArgs> invoked when messages are received on the returned IAsyncSubscription. |
Implemented in NATS.Client.EncodedConnection.
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.
subject | The subject on which to listen for messages. The subject can have wildcards (partial: * , full: > ). |
queue | The name of the queue group in which to participate. |
handler | The EventHandler<TEventArgs> invoked when messages are received on the returned IAsyncSubscription. |
Implemented in NATS.Client.EncodedConnection.
|
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.
|
get |
Gets the maximum size in bytes of any payload sent to the connected NATS Server.
|
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.
|
get |
Gets the current state of the IConnection.
|
get |
Gets the statistics tracked for the IConnection.