Drain the held messages buffer.
Drain the held messages buffer.
This is invoked when the actor is restarted to ensure any held messages are not lost. If this behaviour is not desired, and instead the messages should be dropped, then this method can be overridden to do nothing.
Fast failover settings.
Fast failover settings.
Override if you want to supply your own custom settings.
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.
Support for implementing fast failover.
Simply mix this trait into your actor for transparent handling of fast failover envelopes and heartbeats.
Note that this uses Akka's
aroundReceive
andaroundPreRestart
methods, which may conflict with other actor mix-ins likePersistentActor
. In such cases it may be better to use FastFailoverHelper directly.