=doc #3924 Doc how to be notified when recovery completed
This commit is contained in:
parent
4ba1bc46fb
commit
c1f7d7fa21
7 changed files with 132 additions and 4 deletions
|
|
@ -8,11 +8,9 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import scala.Option;
|
||||
import scala.concurrent.duration.Duration;
|
||||
|
||||
import akka.actor.*;
|
||||
import akka.japi.Procedure;
|
||||
import akka.persistence.*;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class PersistenceDocTest {
|
||||
|
|
@ -122,6 +120,42 @@ public class PersistenceDocTest {
|
|||
@Override
|
||||
public void onReceive(Object message) throws Exception {}
|
||||
}
|
||||
|
||||
class MyProcessor5 extends UntypedProcessor {
|
||||
//#recovery-completed
|
||||
@Override
|
||||
public void preStart() throws Exception {
|
||||
super.preStart();
|
||||
self().tell("FIRST", self());
|
||||
}
|
||||
|
||||
public void onReceive(Object message) throws Exception {
|
||||
if (message.equals("FIRST")) {
|
||||
recoveryCompleted();
|
||||
getContext().become(active);
|
||||
unstashAll();
|
||||
} else if (recoveryFinished()) {
|
||||
stash();
|
||||
} else {
|
||||
active.apply(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void recoveryCompleted() {
|
||||
// perform init after recovery, before any other messages
|
||||
// ...
|
||||
}
|
||||
|
||||
Procedure<Object> active = new Procedure<Object>() {
|
||||
@Override
|
||||
public void apply(Object message) {
|
||||
if (message instanceof Persistent) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
};
|
||||
//#recovery-completed
|
||||
}
|
||||
};
|
||||
|
||||
static Object o3 = new Object() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue