Class NatsSubBase
The base class for NATS subscriptions.
public abstract class NatsSubBase
- Inheritance
-
NatsSubBase
- Derived
- Inherited Members
Constructors
- NatsSubBase(INatsConnection, INatsSubscriptionManager, string, string?, NatsSubOpts?, CancellationToken)
Creates a new instance of NatsSubBase.
Properties
- Connection
Represents a connection to the NATS server.
- EndReason
The reason for the subscription ending.
- Exception
Represents an exception that occurs during the execution of a NATS subscription.
- QueueGroup
If specified, the subscriber will join this queue group. Subscribers with the same queue group name, become a queue group, and only one randomly chosen subscriber of the queue group will consume a message each time a message is received by the queue group.
- Subject
The subject name to subscribe to.
Methods
- DecrementMaxMsgs()
Decrements the maximum number of messages.
- DisposeAsync()
Disposes the instance asynchronously.
- EndSubscription(NatsSubEndReason)
Ends the subscription with the specified reason.
- ReadyAsync()
Signals that the subscription is ready to receive messages. Override this method to perform any initialization logic.
- ReceiveAsync(string, string?, ReadOnlySequence<byte>?, ReadOnlySequence<byte>)
Called when a message is received for the subscription. Calls ReceiveInternalAsync(string, string?, ReadOnlySequence<byte>?, ReadOnlySequence<byte>) to process the message handling any exceptions.
- ReceiveInternalAsync(string, string?, ReadOnlySequence<byte>?, ReadOnlySequence<byte>)
Invoked when a MSG or HMSG arrives for the subscription.
This method is invoked while reading from the socket. Buffers belong to the socket reader and you should process them as quickly as possible or create a copy before you return from this method.
- ResetIdleTimeout()
Resets the idle timeout timer.
- SetException(Exception)
Sets the exception that caused the subscription to end.
- TryComplete()
Invoked to signal end of the subscription.
- UnsubscribeAsync()
Complete the message channel, stop timers if they were used and send an unsubscribe message to the server.