Drain the held messages buffer.
Drain the held messages buffer.
This is offered primarily to allow held messages to not be lost across restarts, and should be invoked from the
preRestart
callback on an actor. It can also be used to manually drain the buffer at any time, but note that
the buffer will automatically be drained once there are no outstanding operations.
Fast failover settings.
Fast failover settings.
Override if you want to supply your own custom settings.
Partial function to handle fast failover messages.
Partial function to handle fast failover messages.
Mix this in with your receive logic, generally it should be mixed in first, in order to be able to buffer messages to hold.
For example:
class MyActor extends Actor { val helper = FastFailoverHelper(context) override def receive = helper.handleFastFailover.orElse { case ... } }
Java API: AbstractActor receive, for composition within AbstractActor support.
Java API: AbstractActor receive, for composition within AbstractActor support.
For example:
public class MyActor extends AbstractActor { private final FastFailoverHelper helper = new FastFailoverHelper(context()); public Receive createReceive() { return helper.handleFastFailoverReceive.orElse( receiveBuilder() .match(...) .build() ); };
Any message that this returns true for will be held by the fast failover support as long as there is an outstanding fast failover message to process.
Any message that this returns true for will be held by the fast failover support as long as there is an outstanding fast failover message to process.
This is useful for implementing graceful shutdown, to block the processing of shutdown messages until all fast failover operations have completed. Note that if more operations continue to arrive, such that this actor never ends up with no active operations, then the messages could end up being held indefinitely.
Messages that get held must be tolerant to reordering, since other messages may arrive during the time that the messages are being held, which will overtake the held messages.
If overriding this function to return true, be sure to implement the actors preRestart
function to invoke
FastFailoverHelper#drainHeldMessages, otherwise the held messages will be dropped.
Helper for actors that execute fast failover operation attempts.
This class can either be instantiated as is, or extended to override the FastFailoverHelper#fastFailoverSettings or FastFailoverHelper#shouldHoldUntilNoOperation methods.
The FastFailoverHelper#handleFastFailover (Scala Actor), FastFailoverHelper#handleFastFailoverReceive (Java AbstractActor) methods can be used to handle fast failover envelopes and heartbeats.