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

Public Member Functions

void Publish (string subject, Object obj)
 
void Publish (string subject, MsgHeader headers, Object obj)
 
void Publish (string subject, string reply, object obj)
 
void Publish (string subject, string reply, MsgHeader headers, object obj)
 
IAsyncSubscription SubscribeAsync (string subject, EventHandler< EncodedMessageEventArgs > handler)
 
IAsyncSubscription SubscribeAsync (string subject, string queue, EventHandler< EncodedMessageEventArgs > handler)
 
object Request (string subject, object obj, int timeout)
 
object Request (string subject, MsgHeader headers, object obj, int timeout)
 
object Request (string subject, object obj)
 
object Request (string subject, MsgHeader headers, object obj)
 
- Public Member Functions inherited from NATS.Client.Connection
void Publish (string subject, byte[] data)
 
void Publish (string subject, MsgHeader headers, byte[] data)
 
void Publish (string subject, byte[] data, int offset, int count)
 
void Publish (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
void Publish (string subject, string reply, byte[] data)
 
void Publish (string subject, string reply, MsgHeader headers, byte[] data)
 
void Publish (string subject, string reply, byte[] data, int offset, int count)
 
void Publish (string subject, string reply, MsgHeader headers, byte[] data, int offset, int count)
 
void Publish (Msg msg)
 
Msg Request (string subject, byte[] data, int timeout)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int timeout)
 
Msg Request (string subject, byte[] data, int offset, int count, int timeout)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int offset, int count, int timeout)
 
Msg Request (string subject, byte[] data)
 
Msg Request (string subject, MsgHeader headers, byte[] data)
 
Msg Request (string subject, byte[] data, int offset, int count)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
Msg Request (Msg message, int timeout)
 
Msg Request (Msg message)
 
Task< MsgRequestAsync (string subject, byte[] data, int timeout)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int timeout)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count, int timeout)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count, int timeout)
 
Task< MsgRequestAsync (string subject, byte[] data)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
Task< MsgRequestAsync (string subject, byte[] data, int timeout, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int timeout, CancellationToken token)
 
Task< MsgRequestAsync (string subject, byte[] data, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, CancellationToken token)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count, CancellationToken token)
 
Task< MsgRequestAsync (Msg message, int timeout)
 
Task< MsgRequestAsync (Msg message)
 
Task< MsgRequestAsync (Msg message, int timeout, CancellationToken token)
 
Task< MsgRequestAsync (Msg message, CancellationToken token)
 
string NewInbox ()
 
ISyncSubscription SubscribeSync (string subject)
 
IAsyncSubscription SubscribeAsync (string subject)
 
IAsyncSubscription SubscribeAsync (string subject, EventHandler< MsgHandlerEventArgs > handler)
 
ISyncSubscription SubscribeSync (string subject, string queue)
 
IAsyncSubscription SubscribeAsync (string subject, string queue)
 
IAsyncSubscription SubscribeAsync (string subject, string queue, EventHandler< MsgHandlerEventArgs > handler)
 
void Flush (int timeout)
 
TimeSpan RTT ()
 
void Flush ()
 
void FlushBuffer ()
 
void Close ()
 
bool IsClosed ()
 
void Drain ()
 
void Drain (int timeout)
 
Task DrainAsync ()
 
Task DrainAsync (int timeout)
 
bool IsDraining ()
 
bool IsReconnecting ()
 
void ResetStats ()
 
override string ToString ()
 
void Dispose ()
 
IStreamContext GetStreamContext (string streamName)
 
IStreamContext GetStreamContext (string streamName, JetStreamOptions options)
 
IConsumerContext GetConsumerContext (string streamName, string consumerName)
 
IConsumerContext GetConsumerContext (string streamName, string consumerName, JetStreamOptions options)
 
IJetStream CreateJetStreamContext (JetStreamOptions options=null)
 
IJetStreamManagement CreateJetStreamManagementContext (JetStreamOptions options=null)
 
IKeyValue CreateKeyValueContext (string bucketName, KeyValueOptions options=null)
 
IKeyValueManagement CreateKeyValueManagementContext (KeyValueOptions options=null)
 
IObjectStore CreateObjectStoreContext (string bucketName, ObjectStoreOptions options=null)
 
IObjectStoreManagement CreateObjectStoreManagementContext (ObjectStoreOptions options=null)
 
void Publish (string subject, byte[] data)
 
void Publish (string subject, MsgHeader headers, byte[] data)
 
void Publish (string subject, byte[] data, int offset, int count)
 
void Publish (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
void Publish (string subject, string reply, byte[] data)
 
void Publish (string subject, string reply, MsgHeader headers, byte[] data)
 
void Publish (string subject, string reply, byte[] data, int offset, int count)
 
void Publish (string subject, string reply, MsgHeader headers, byte[] data, int offset, int count)
 
void Publish (Msg msg)
 
Msg Request (string subject, byte[] data, int timeout)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int timeout)
 
Msg Request (string subject, byte[] data, int offset, int count, int timeout)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int offset, int count, int timeout)
 
Msg Request (string subject, byte[] data)
 
Msg Request (string subject, MsgHeader headers, byte[] data)
 
Msg Request (string subject, byte[] data, int offset, int count)
 
Msg Request (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
Msg Request (Msg message)
 
Msg Request (Msg message, int timeout)
 
Task< MsgRequestAsync (string subject, byte[] data, int timeout)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int timeout)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count, int timeout)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count, int timeout)
 
Task< MsgRequestAsync (string subject, byte[] data)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count)
 
Task< MsgRequestAsync (string subject, byte[] data, int timeout, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int timeout, CancellationToken token)
 
Task< MsgRequestAsync (string subject, byte[] data, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, CancellationToken token)
 
Task< MsgRequestAsync (string subject, byte[] data, int offset, int count, CancellationToken token)
 
Task< MsgRequestAsync (string subject, MsgHeader headers, byte[] data, int offset, int count, CancellationToken token)
 
Task< MsgRequestAsync (Msg message)
 
Task< MsgRequestAsync (Msg message, int timeout)
 
Task< MsgRequestAsync (Msg message, CancellationToken token)
 
Task< MsgRequestAsync (Msg message, int timeout, CancellationToken token)
 
string NewInbox ()
 
ISyncSubscription SubscribeSync (string subject)
 
IAsyncSubscription SubscribeAsync (string subject)
 
IAsyncSubscription SubscribeAsync (string subject, EventHandler< MsgHandlerEventArgs > handler)
 
ISyncSubscription SubscribeSync (string subject, string queue)
 
IAsyncSubscription SubscribeAsync (string subject, string queue)
 
IAsyncSubscription SubscribeAsync (string subject, string queue, EventHandler< MsgHandlerEventArgs > handler)
 
void Flush (int timeout)
 
TimeSpan RTT ()
 
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 ()
 
IStreamContext GetStreamContext (string streamName)
 
IStreamContext GetStreamContext (string streamName, JetStreamOptions options)
 
IConsumerContext GetConsumerContext (string streamName, string consumerName)
 
IConsumerContext GetConsumerContext (string streamName, string consumerName, JetStreamOptions options)
 
IJetStream CreateJetStreamContext (JetStreamOptions options=null)
 
IJetStreamManagement CreateJetStreamManagementContext (JetStreamOptions options=null)
 
IKeyValue CreateKeyValueContext (string bucketName, KeyValueOptions options=null)
 
IKeyValueManagement CreateKeyValueManagementContext (KeyValueOptions options=null)
 
IObjectStore CreateObjectStoreContext (string bucketName, ObjectStoreOptions options=null)
 
IObjectStoreManagement CreateObjectStoreManagementContext (ObjectStoreOptions options=null)
 
- Public Member Functions inherited from NATS.Client.IEncodedConnection
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 ()
 

Protected Member Functions

override void Dispose (bool disposing)
 
virtual void Dispose (bool disposing)
 

Properties

Serializer OnSerialize [get, set]
 
Deserializer OnDeserialize [get, set]
 
- Properties inherited from NATS.Client.Connection
Options Opts [get]
 
string ConnectedUrl [get]
 
IPAddress ClientIP [get]
 
int ClientID [get]
 
string ConnectedId [get]
 
ServerInfo ServerInfo [get]
 
string[] Servers [get]
 
string[] DiscoveredServers [get]
 
Exception LastError [get]
 
ConnState State [get]
 
int SubscriptionCount [get]
 
IStatistics Stats [get]
 
long MaxPayload [get]
 
- Properties inherited from NATS.Client.IConnection
Options Opts [get]
 
IPAddress ClientIP [get]
 
int ClientID [get]
 
string ConnectedUrl [get]
 
string ConnectedId [get]
 
ServerInfo ServerInfo [get]
 
string[] Servers [get]
 
string[] DiscoveredServers [get]
 
Exception LastError [get]
 
ConnState State [get]
 
IStatistics Stats [get]
 
long MaxPayload [get]
 
int SubscriptionCount [get]
 
- Properties inherited from NATS.Client.IEncodedConnection
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 an Connection which uses a client specified encoding scheme.

Member Function Documentation

◆ Dispose()

override void NATS.Client.EncodedConnection.Dispose ( bool  disposing)
protectedvirtual

Closes the EncodedConnection and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented from NATS.Client.Connection.

◆ Publish() [1/4]

void NATS.Client.EncodedConnection.Publish ( string  subject,
MsgHeader  headers,
Object  obj 
)

Publishes the serialized value of obj to the given subject .

Parameters
subjectThe subject to publish obj to over the current connection.
headersOptional headers to publish with the message.
objThe Object to serialize and publish to the connected NATS server.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSExceptionOnSerialize is null.-or-There was an unexpected exception performing an internal NATS call while publishing. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

◆ Publish() [2/4]

void NATS.Client.EncodedConnection.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.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSExceptionOnSerialize is null.-or-There was an unexpected exception performing an internal NATS call while publishing. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

◆ Publish() [3/4]

void NATS.Client.EncodedConnection.Publish ( string  subject,
string  reply,
MsgHeader  headers,
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.
headersOptional headers to publish with the message.
objThe Object to serialize and publish to the connected NATS server.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSExceptionOnSerialize is null.-or-There was an unexpected exception performing an internal NATS call while publishing. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ Publish() [4/4]

void NATS.Client.EncodedConnection.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.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSExceptionOnSerialize is null.-or-There was an unexpected exception performing an internal NATS call while publishing. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ Request() [1/4]

object NATS.Client.EncodedConnection.Request ( string  subject,
MsgHeader  headers,
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.
headersOptional headers to publish with the message.
objThe Object to serialize and publish to the connected NATS server.
Returns
A Object with the deserialized response from the NATS server.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSTimeoutExceptionA timeout occurred while sending the request or receiving the response.
NATSExceptionThere was an unexpected exception performing an internal NATS call while executing the request. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ Request() [2/4]

object NATS.Client.EncodedConnection.Request ( string  subject,
MsgHeader  headers,
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.
headersOptional headers to publish with the message.
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.
Exceptions
ArgumentOutOfRangeExceptiontimeout is less than or equal to zero (0).
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSTimeoutExceptionA timeout occurred while sending the request or receiving the response.
NATSExceptionThere was an unexpected exception performing an internal NATS call while executing the request. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ Request() [3/4]

object NATS.Client.EncodedConnection.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.
Exceptions
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSTimeoutExceptionA timeout occurred while sending the request or receiving the response.
NATSExceptionThere was an unexpected exception performing an internal NATS call while executing the request. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ Request() [4/4]

object NATS.Client.EncodedConnection.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.
Exceptions
ArgumentOutOfRangeExceptiontimeout is less than or equal to zero (0).
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSMaxPayloadExceptionobj exceeds the maximum payload size supported by the NATS server.
NATSConnectionClosedExceptionThe Connection is closed.
NATSTimeoutExceptionA timeout occurred while sending the request or receiving the response.
NATSExceptionThere was an unexpected exception performing an internal NATS call while executing the request. See System.Exception.InnerException for more details.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ SubscribeAsync() [1/2]

IAsyncSubscription NATS.Client.EncodedConnection.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 .
Exceptions
ArgumentNullExceptionhandler is null.
NATSExceptionOnDeserialize is null.
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSConnectionClosedExceptionThe Connection is closed.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

◆ SubscribeAsync() [2/2]

IAsyncSubscription NATS.Client.EncodedConnection.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 .
Exceptions
ArgumentNullExceptionhandler is null.
NATSExceptionOnDeserialize is null.
NATSBadSubscriptionExceptionsubject is null or entirely whitespace.
NATSConnectionClosedExceptionThe Connection is closed.
IOExceptionThere was a failure while writing to the network.

Implements NATS.Client.IEncodedConnection.

Property Documentation

◆ OnDeserialize

Deserializer NATS.Client.EncodedConnection.OnDeserialize
getset

Gets or sets the method which is called to deserialize objects from a message payload.

If null is given then the default deserialization method for the platform is used, if one exists.

Implements NATS.Client.IEncodedConnection.

◆ OnSerialize

Serializer NATS.Client.EncodedConnection.OnSerialize
getset

Gets or sets the method which is called to serialize objects sent as a message payload.

If null is given then the default serialization method for the platform is used, if one exists.

Implements NATS.Client.IEncodedConnection.


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