ActorPublisherT Class |
Extend this actor to make it a stream publisher that keeps track of the subscription life cycle and requested elements.
Create a IPublisher backed by this actor with CreateT(IActorRef).
It can be attached to a ISubscriber or be used as an input source for a IFlowTOut, TMat. You can only attach one subscriber to this publisher.
The life cycle state of the subscription is tracked with the following boolean members: IsActive, IsCompleted, IsErrorEmitted, and IsCanceled.
You send elements to the stream by calling OnNext(T). You are allowed to send as many elements as have been requested by the stream subscriber. This amount can be inquired with TotalDemand. It is only allowed to use OnNext(T) when IsActiveTotalDemand > 0, otherwise OnNext(T) will throw IllegalStateException.
When the stream subscriber requests more elements the Request message is delivered to this actor, and you can act on that event. The TotalDemand is updated automatically.
When the stream subscriber cancels the subscription the Cancel message is delivered to this actor. After that subsequent calls to OnNext(T) will be ignored.
You can complete the stream by calling OnComplete. After that you are not allowed to call OnNext(T), OnError(Exception) and OnComplete.
You can terminate the stream with failure by calling OnError(Exception). After that you are not allowed to call OnNext(T), OnError(Exception) and OnComplete.
If you suspect that this ActorPublisherT may never get subscribed to, you can override the SubscriptionTimeout method to provide a timeout after which this Publisher should be considered canceled. The actor will be notified when the timeout triggers via an SubscriptionTimeoutExceeded message and MUST then perform cleanup and stop itself.
If the actor is stopped the stream will be completed, unless it was not already terminated with failure, completed or canceled.
Namespace: Akka.Streams.Actors
The ActorPublisherT type exposes the following members.
Name | Description | |
---|---|---|
ActorPublisherT |
TBD
|
Name | Description | |
---|---|---|
IsActive |
The state when the publisher is active, i.e. before the subscriber is attached
and when an subscriber is attached. It is allowed to
call OnComplete and OnError(Exception) in this state. It is
allowed to call OnNext(T) in this state when TotalDemand
is greater than zero.
| |
IsCanceled |
The state after the stream subscriber has canceled the subscription.
It is allowed to call OnNext(T), OnError(Exception), and OnComplete in
this state, but the calls will not perform anything.
| |
IsCompleted |
The terminal state after calling OnComplete. It is not allowed to
OnNext(T), OnError(Exception), and OnComplete in this state.
| |
IsErrorEmitted |
The terminal state after calling OnError(Exception). It is not allowed to
call OnNext(T), OnError(Exception), and OnComplete in this state.
| |
Self |
Gets the self ActorRef
(Inherited from ActorBase.) | |
Sender |
Gets the sending ActorRef of the current message
(Inherited from ActorBase.) | |
SubscriptionTimeout |
Subscription timeout after which this actor will become Canceled and reject any incoming "late" subscriber.
The actor will receive an SubscriptionTimeoutExceeded message upon which it
MUST react by performing all necessary cleanup and stopping itself.
Use this feature in order to avoid leaking actors when you suspect that this Publisher may never get subscribed to by some Subscriber.
| |
TotalDemand |
Total number of requested elements from the stream subscriber.
This actor automatically keeps tracks of this amount based on
incoming request messages and outgoing OnNext(T).
|
Name | Description | |
---|---|---|
AroundPostRestart |
TBD
(Overrides ActorBaseAroundPostRestart(Exception, Object).) | |
AroundPostStop |
TBD
(Overrides ActorBaseAroundPostStop.) | |
AroundPreRestart |
TBD
(Overrides ActorBaseAroundPreRestart(Exception, Object).) | |
AroundPreStart |
TBD
(Overrides ActorBaseAroundPreStart.) | |
AroundReceive |
TBD
(Overrides ActorBaseAroundReceive(Receive, Object).) | |
Become |
Changes the actor's command behavior and replaces the current receive handler with the specified handler.
(Inherited from ActorBase.) | |
BecomeStacked |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
The current handler is stored on a stack, and you can revert to it by calling UnbecomeStacked (Inherited from ActorBase.)Remarks Please note, that in order to not leak memory, make sure every call to BecomeStacked(Receive)
is matched with a call to UnbecomeStacked. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnComplete |
Complete the stream. After that you are not allowed to
call OnNext(T), OnError(Exception) and OnComplete.
| |
OnCompleteThenStop | Complete the stream. After that you are not allowed to call OnNext(T), OnError(Exception) and OnComplete. After signalling completion the Actor will then stop itself as it has completed the protocol. When OnComplete is called before any ISubscriber has had the chance to subscribe to this ActorPublisherT the completion signal (and therefore stopping of the Actor as well) will be delayed until such ISubscriber arrives. | |
OnError |
Terminate the stream with failure. After that you are not allowed to
call OnNext(T), OnError(Exception) and OnComplete.
| |
OnErrorThenStop | Terminate the stream with failure. After that you are not allowed to call OnNext(T), OnError(Exception) and OnComplete. After signalling the Error the Actor will then stop itself as it has completed the protocol. When OnError(Exception) is called before any ISubscriber has had the chance to subscribe to this ActorPublisherT the error signal (and therefore stopping of the Actor as well) will be delayed until such ISubscriber arrives. | |
OnNext |
Sends an element to the stream subscriber. You are allowed to send as many elements
as have been requested by the stream subscriber. This amount can be inquired with
TotalDemand. It is only allowed to use OnNext(T) when
IsActive and TotalDemand > 0,
otherwise OnNext(T) will throw IllegalStateException.
| |
PostRestart |
User overridable callback: By default it calls `PreStart()`.
Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
(Inherited from ActorBase.) | |
PostStop |
User overridable callback.
Is called asynchronously after 'actor.stop()' is invoked.
Empty default implementation.
(Inherited from ActorBase.) | |
PreRestart |
User overridable callback: '''By default it disposes of all children and then calls `postStop()`.'''
Is called on a crashed Actor right BEFORE it is restarted to allow clean
up of resources before Actor is terminated.
(Inherited from ActorBase.) | |
PreStart |
User overridable callback.
Is called when an Actor is started.
Actors are automatically started asynchronously when created.
Empty default implementation.
(Inherited from ActorBase.) | |
Receive |
Processor for user defined messages.
(Inherited from ActorBase.) | |
SetReceiveTimeout | Defines the inactivity timeout after which the sending of a ReceiveTimeout message is triggered. When specified, the receive function should be able to handle a ReceiveTimeout message. Please note that the receive timeout might fire and enqueue the ReceiveTimeout message right after another message was enqueued; hence it is not guaranteed that upon reception of the receive timeout there must have been an idle period beforehand as configured via this method. Once set, the receive timeout stays in effect (i.e. continues firing repeatedly after inactivity periods). Pass in null to switch off this feature. | |
SupervisorStrategy |
TBD
(Inherited from ActorBase.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UnbecomeStacked |
Reverts the Actor behavior to the previous one on the behavior stack.
(Inherited from ActorBase.) | |
Unhandled |
Is called when a message isn't handled by the current behavior of the actor
by default it fails with either a DeathPactException (in
case of an unhandled Terminated message) or publishes an UnhandledMessage
to the actor's system's EventStream (Inherited from ActorBase.) |
Name | Description | |
---|---|---|
AsInstanceOfT |
TBD
(Defined by Extensions.) | |
Match | Overloaded.
Matches the specified target.
(Defined by PatternMatch.) | |
MatchT | Overloaded.
Matches the specified target and return a result of target processing.
(Defined by PatternMatch.) |