public class FastFailoverHelper
extends java.lang.Object
This class can either be instantiated as is, or extended to override the
fastFailoverSettings() or
shouldHoldUntilNoOperation(java.lang.Object) methods.
The handleFastFailover() (Scala Actor),
handleFastFailoverReceive() (Java AbstractActor) methods can be used to handle fast failover
envelopes and heartbeats.
| Modifier and Type | Class and Description |
|---|---|
static class |
FastFailoverHelper.AttemptResult |
static class |
FastFailoverHelper.AttemptResult$ |
static class |
FastFailoverHelper.Forward
This message can be sent as the reply to a fast failover operation to allow handling of the operation to be
forwarded to another actor.
|
static class |
FastFailoverHelper.Forward$ |
static class |
FastFailoverHelper.ForwardPattern |
| Constructor and Description |
|---|
FastFailoverHelper(akka.actor.ActorContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
drainHeldMessages()
Drain the held messages buffer.
|
FastFailoverSettings |
fastFailoverSettings()
Fast failover settings.
|
static FastFailoverHelper.ForwardPattern |
ForwardPattern(akka.actor.ActorRef to) |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
handleFastFailover()
Partial function to handle fast failover messages.
|
akka.actor.AbstractActor.Receive |
handleFastFailoverReceive()
Java API: AbstractActor receive, for composition within AbstractActor support.
|
boolean |
shouldHoldUntilNoOperation(java.lang.Object msg)
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.
|
public static FastFailoverHelper.ForwardPattern ForwardPattern(akka.actor.ActorRef to)
public FastFailoverSettings fastFailoverSettings()
Override if you want to supply your own custom settings.
public boolean shouldHoldUntilNoOperation(java.lang.Object msg)
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
drainHeldMessages(), otherwise the held messages will be dropped.
msg - (undocumented)public final scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> handleFastFailover()
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 ...
}
}
public final akka.actor.AbstractActor.Receive handleFastFailoverReceive()
For example:
public class MyActor extends AbstractActor {
private final FastFailoverHelper helper = new FastFailoverHelper(context());
public Receive createReceive() {
return helper.handleFastFailoverReceive.orElse(
receiveBuilder()
.match(...)
.build()
);
};
public final void drainHeldMessages()
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.