NATS .NET Client  1.1.4
The NATS.io .NET C# Client
NATS.Client.ISubscription Interface Reference
Inheritance diagram for NATS.Client.ISubscription:
NATS.Client.AsyncSubscription NATS.Client.IAsyncSubscription NATS.Client.ISyncSubscription NATS.Client.Subscription NATS.Client.SyncSubscription NATS.Client.AsyncSubscription NATS.Client.JetStream.IJetStreamPullAsyncSubscription NATS.Client.JetStream.IJetStreamPushAsyncSubscription NATS.Client.JetStream.IJetStreamPullSubscription NATS.Client.JetStream.IJetStreamPushSyncSubscription NATS.Client.SyncSubscription NATS.Client.AsyncSubscription NATS.Client.SyncSubscription

Public Member Functions

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)
 

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]
 

Detailed Description

Represents interest in a NATS topic.

Subscriptions represent interest in a topic on a NATS Server or cluster of NATS Servers. Subscriptions can be exact or include wildcards. A subscriber can process a NATS message synchronously (ISyncSubscription) or asynchronously (IAsyncSubscription).

See also
ISyncSubscription, IAsyncSubscription

Member Function Documentation

◆ AutoUnsubscribe()

void NATS.Client.ISubscription.AutoUnsubscribe ( int  max)

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.

Implemented in NATS.Client.AsyncSubscription, and NATS.Client.Subscription.

◆ Drain() [1/2]

void NATS.Client.ISubscription.Drain ( )

Drains a subscription for gracefully unsubscribing.

This method unsubscribes the subscriber and drains all remaining messages.

See also
Unsubscribe()

Implemented in NATS.Client.Subscription.

◆ Drain() [2/2]

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

Drains a subscription for gracefully unsubscribing.

Parameters
timeoutThe duration in milliseconds to wait while draining.


///

See also
Unsubscribe()

Implemented in NATS.Client.Subscription.

◆ DrainAsync() [1/2]

Task NATS.Client.ISubscription.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.

Implemented in NATS.Client.Subscription.

◆ DrainAsync() [2/2]

Task NATS.Client.ISubscription.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.

Implemented in NATS.Client.Subscription.

◆ GetMaxPending()

void NATS.Client.ISubscription.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.

Implemented in NATS.Client.Subscription.

◆ GetPending()

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

Returns the 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.

Implemented in NATS.Client.Subscription.

◆ SetPendingLimits()

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

Sets the limits for pending messages and bytes for this instance.

Zero (0) is not allowed. Negative values indicate that the given metric is not limited.

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

Implemented in NATS.Client.Subscription.

Property Documentation

◆ Dropped

long NATS.Client.ISubscription.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.

Implemented in NATS.Client.Subscription.

◆ PendingByteLimit

long NATS.Client.ISubscription.PendingByteLimit
getset

Gets or sets the maximum allowed count of pending bytes.

The limit must not be zero (0). Negative values indicate there is no limit on the number of pending bytes.

Implemented in NATS.Client.Subscription.

◆ PendingMessageLimit

long NATS.Client.ISubscription.PendingMessageLimit
getset

Gets or sets the maximum allowed count of pending messages.

The limit must not be zero (0). Negative values indicate there is no limit on the number of pending messages.

Implemented in NATS.Client.Subscription.

◆ Queue

string NATS.Client.ISubscription.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. Although queue groups have multiple subscribers, each message is consumed by only one.

Implemented in NATS.Client.Subscription.

◆ Subject

string NATS.Client.ISubscription.Subject
get

Gets the subject for this subscription.

Subject names, including reply subject (INBOX) names, are case-sensitive and must be non-empty alphanumeric strings with no embedded whitespace, and optionally token-delimited using the dot character (.), e.g.: FOO, BAR, foo.BAR, FOO.BAR, and FOO.BAR.BAZ are all valid subject names, while: FOO. BAR, foo. .bar and foo..bar are not valid subject names.

NATS supports the use of wildcards in subject subscriptions.

  • The asterisk character (*) matches any token at any level of the subject.
  • The greater than symbol (>), also known as the full wildcard, matches one or more tokens at the tail of a subject, and must be the last token. The wildcard subject foo.> will match foo.bar or foo.bar.baz.1, but not foo.
  • Wildcards must be separate tokens (foo.*.bar or foo.> are syntactically valid; foo*.bar, f*o.b*r and foo> are not).

For example, the wildcard subscriptions foo.*.quux and foo.> both match foo.bar.quux, but only the latter matches foo.bar.baz. With the full wildcard, it is also possible to express interest in every subject that may exist in NATS (>).

Implemented in NATS.Client.Subscription.


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