NATS .NET Client  1.1.4
The NATS.io .NET C# Client
NATS.Client.Subscription Class Reference
Inheritance diagram for NATS.Client.Subscription:
NATS.Client.ISubscription NATS.Client.AsyncSubscription NATS.Client.SyncSubscription

Public Member Functions

virtual void Unsubscribe ()
 
virtual void AutoUnsubscribe (int max)
 
void Dispose ()
 
override string ToString ()
 
void SetPendingLimits (long messageLimit, long bytesLimit)
 
void GetPending (out long pendingBytes, out long pendingMessages)
 
void GetMaxPending (out long maxPendingBytes, out long maxPendingMessages)
 
void ClearMaxPending ()
 
Task DrainAsync ()
 
Task DrainAsync (int timeout)
 
void Drain ()
 
void Drain (int timeout)
 
void Unsubscribe ()
 
void AutoUnsubscribe (int max)
 
void SetPendingLimits (long messageLimit, long bytesLimit)
 
void GetPending (out long pendingBytes, out long pendingMessages)
 
void GetMaxPending (out long maxPendingBytes, out long maxPendingMessages)
 
void ClearMaxPending ()
 
void Drain ()
 
void Drain (int timeout)
 
Task DrainAsync ()
 
Task DrainAsync (int timeout)
 

Static Public Member Functions

static bool IsValidSubject (string subject)
 
static bool IsValidPrefix (string prefix)
 
static bool IsValidQueueGroupName (string queueGroup)
 

Protected Member Functions

long tallyDeliveredMessage (Msg msg)
 
virtual void Dispose (bool disposing)
 

Properties

long Sid [get]
 
string Subject [get]
 
string Queue [get]
 
Connection Connection [get]
 
bool IsValid [get]
 
int QueuedMessageCount [get]
 
long PendingByteLimit [get, set]
 
long PendingMessageLimit [get, set]
 
long PendingBytes [get]
 
long PendingMessages [get]
 
long MaxPendingBytes [get]
 
long MaxPendingMessages [get]
 
long Delivered [get]
 
long Dropped [get]
 
- Properties inherited from NATS.Client.ISubscription
long Sid [get]
 
string Subject [get]
 
string Queue [get]
 
Connection Connection [get]
 
bool IsValid [get]
 
int QueuedMessageCount [get]
 
long PendingByteLimit [get, set]
 
long PendingMessageLimit [get, set]
 
long PendingBytes [get]
 
long PendingMessages [get]
 
long MaxPendingBytes [get]
 
long MaxPendingMessages [get]
 
long Delivered [get]
 
long Dropped [get]
 

Detailed Description

Represents interest in a NATS topic. This class should not be used directly.

Member Function Documentation

◆ AutoUnsubscribe()

virtual void NATS.Client.Subscription.AutoUnsubscribe ( int  max)
virtual

Issues an automatic call to Unsubscribe when max messages have been received.

This can be useful when sending a request to an unknown number of subscribers. Connection's Request methods use this functionality.

Parameters
maxThe maximum number of messages to receive on the subscription before calling Unsubscribe. Values less than or equal to zero (0) unsubscribe immediately.
Exceptions
NATSBadSubscriptionExceptionThere is no longer an associated Connection for this ISubscription.

Implements NATS.Client.ISubscription.

Reimplemented in NATS.Client.AsyncSubscription.

◆ Dispose() [1/2]

void NATS.Client.Subscription.Dispose ( )

Releases all resources used by the Subscription.

This method unsubscribes from the subject, to release resources.

◆ Dispose() [2/2]

virtual void NATS.Client.Subscription.Dispose ( bool  disposing)
protectedvirtual

Unsubscribes the subscription and optionally releases the managed resources.

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

◆ Drain() [1/2]

void NATS.Client.Subscription.Drain ( )

Drains a subscription for gracefully unsubscribing.

This method unsubscribes the subscriber and drains all remaining messages.

See also
Unsubscribe()

Implements NATS.Client.ISubscription.

◆ Drain() [2/2]

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

Drains a subscription for gracefully unsubscribing.

Parameters
timeoutThe duration in milliseconds to wait while draining.


///

See also
Unsubscribe()

Implements NATS.Client.ISubscription.

◆ DrainAsync() [1/2]

Task NATS.Client.Subscription.DrainAsync ( )

Drains a subscription for gracefully unsubscribing.

This method unsubscribes the subscriber and drains all remaining messages.

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

Implements NATS.Client.ISubscription.

◆ DrainAsync() [2/2]

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

Drains a subscription for gracefully unsubscribing.

Parameters
timeoutThe duration in milliseconds to wait while draining.


///

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

Implements NATS.Client.ISubscription.

◆ GetMaxPending()

void NATS.Client.Subscription.GetMaxPending ( out long  maxPendingBytes,
out long  maxPendingMessages 
)

Returns the maximum number of pending bytes and messages during the life of the Subscription.

Parameters
maxPendingBytesWhen this method returns, maxPendingBytes will contain the current maximum pending bytes.
maxPendingMessagesWhen this method returns, maxPendingBytes will contain the current maximum pending messages.

Implements NATS.Client.ISubscription.

◆ GetPending()

void NATS.Client.Subscription.GetPending ( out long  pendingBytes,
out long  pendingMessages 
)

Returns the yet processed pending byte and message counts.

Parameters
pendingBytesWhen this method returns, pendingBytes will contain the count of bytes not yet processed on the ISubscription.
pendingMessagesWhen this method returns, pendingMessages will contain the count of messages not yet processed on the ISubscription.

Implements NATS.Client.ISubscription.

◆ IsValidPrefix()

static bool NATS.Client.Subscription.IsValidPrefix ( string  prefix)
static

Checks if a prefix is valid.

Parameters
prefix
Returns

◆ IsValidQueueGroupName()

static bool NATS.Client.Subscription.IsValidQueueGroupName ( string  queueGroup)
static

Checks if the queue group name is valid.

Parameters
queueGroup
Returns
true is the queue group name is valid, false otherwise.

◆ IsValidSubject()

static bool NATS.Client.Subscription.IsValidSubject ( string  subject)
static

Checks if a subject is valid.

Parameters
subjectThe subject to check
Returns
true if valid, false otherwise.

◆ SetPendingLimits()

void NATS.Client.Subscription.SetPendingLimits ( long  messageLimit,
long  bytesLimit 
)

Sets the limits for pending messages and bytes for this instance. Any value less than or equal to zero means unlimited and will be stored as -1.

Parameters
messageLimitThe maximum number of pending messages.
bytesLimitThe maximum number of pending bytes of payload.

Implements NATS.Client.ISubscription.

◆ tallyDeliveredMessage()

long NATS.Client.Subscription.tallyDeliveredMessage ( Msg  msg)
protected

Implementors should call this method when msg has been delivered to an ISubscription.

Caller must lock on mu.

Parameters
msgThe Msg object delivered to a ISubscription.
Returns
The total number of delivered messages.

◆ ToString()

override string NATS.Client.Subscription.ToString ( )

Returns a string that represents the current instance.

Returns
A string that represents the current Subscription.

◆ Unsubscribe()

virtual void NATS.Client.Subscription.Unsubscribe ( )
virtual

Removes interest in the Subject.

Exceptions
NATSBadSubscriptionExceptionThere is no longer an associated Connection
NATSConnectionDrainingExceptionThe Connection is draining. for this ISubscription.

Implements NATS.Client.ISubscription.

Reimplemented in NATS.Client.AsyncSubscription.

Property Documentation

◆ Dropped

long NATS.Client.Subscription.Dropped
get

Gets the number of known dropped messages for this instance.

This will correspond to the messages dropped by violations of PendingByteLimit and/or PendingMessageLimit. If the NATS server declares the connection a slow consumer, the count may not be accurate.

Implements NATS.Client.ISubscription.

◆ PendingByteLimit

long NATS.Client.Subscription.PendingByteLimit
getset

Gets or sets the maximum allowed count of pending bytes.

The pending byte limit if greater than 0 or -1 for unlimited.

Implements NATS.Client.ISubscription.

◆ PendingMessageLimit

long NATS.Client.Subscription.PendingMessageLimit
getset

Gets or sets the maximum allowed count of pending messages.

The pending message limit if greater than 0 or -1 for unlimited.

Implements NATS.Client.ISubscription.

◆ Queue

string NATS.Client.Subscription.Queue
get

Gets the optional queue group name.

If present, all subscriptions with the same name will form a distributed queue, and each message will only be processed by one member of the group.

Implements NATS.Client.ISubscription.

◆ QueuedMessageCount

int NATS.Client.Subscription.QueuedMessageCount
get

Gets the number of messages remaining in the delivery queue.

Exceptions
NATSBadSubscriptionExceptionThere is no longer an associated Connection for this ISubscription.

Implements NATS.Client.ISubscription.


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