PersistentSubscription class

Represents a persistent subscription connection.

This class maintains the state of the subscription, the progress along the stream, the stream of ResolvedEvents and SubscriptionDroppedEvent about the SubscriptionDroppedEvent.cause and SubscriptionDroppedEvent.reason why the subscription onDropped.

If you need to add multiple listeners to the stream, you should use asBroadcastStream. When you are finished using the subscription, you need to dispose it to close the connection to the server and release resources to prevent memory leaks.

Inheritance

Constructors

PersistentSubscription(StreamSink<ReadReq> requests, ReadEnumerator<GeneratedMessage> enumerator, {required bool autoAck, required Future<void> onReplay(int? startAt), PersistentSubscriptionResolvedEventCallback? onEventAppeared, SubscriptionDroppedCallback? onSubscriptionDropped})

Properties

autoAck bool
Acknowledge resolved events automatically when processed
final
checkpoints Stream<SubscriptionCheckPoint>
Stream of SubscriptionCheckPoints
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isCompleted bool
Check if operation has completed. Operation is completed when all events are fetched with stream, or after dispose is called.
no setterinherited
isOK bool
Check if read result is OK
no setterinherited
isStreamNotFound bool
Check if stream was not found
no setterinherited
onDropped Future<SubscriptionDroppedEvent>
Completes when SubscriptionDroppedReason is given
latefinalinherited
position LogPosition
Get current LogPosition. Returns LogPosition.end until first event is received.
no setterinherited
progress StreamState
Current StreamState progress
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ReadState
The StreamState after the operation.
no setterinherited
stream Stream<ResolvedEvent>
Get resolved events as single-subscriber stream
no setterinherited
streamId String
Get StreamState.streamId
no setterinherited
subscriptionId String
The id of the PersistentSubscription set by the server. Returns null if subscription failed.
no setteroverride

Methods

ack(Iterable<ResolvedEvent> events) → void
Acknowledge that client has completed processing given events (this will tell the server it has been processed). There is no need to ack a message if you have autoAck is enabled.
asBroadcastStream() Stream<ResolvedEvent>
Get resolved events as broadcast stream
inherited
dispose() Future<void>
Dispose subscription
override
nack(Iterable<ResolvedEvent> events, String reason, PersistentSubscriptionNackEventAction action) → void
Acknowledge that the client has failed processing given events (this will tell the server it has not been processed). Use PersistentSubscriptionNackEventAction to specify which action the server should take. Use String to log a reason.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replay([int? stopAt]) Future<void>
Replay the parked messages for this subscription.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited