+per #15424 Added PersistentView, deprecated View
A PersistentView works the same way as View did previously, except: * it requires an `peristenceId` (no default is provided) * messages given to `receive` are NOT wrapped in Persistent() akka-streams not touched, will update them afterwards on different branch Also solves #15436 by making persistentId in PersistentView abstract. (cherry picked from commit dcafaf788236fe6d018388dd55d5bf9650ded696) Conflicts: akka-docs/rst/java/lambda-persistence.rst akka-docs/rst/java/persistence.rst akka-docs/rst/scala/persistence.rst akka-persistence/src/main/scala/akka/persistence/Persistent.scala akka-persistence/src/main/scala/akka/persistence/View.scala
This commit is contained in:
parent
2203968adb
commit
3fd240384c
22 changed files with 847 additions and 192 deletions
|
|
@ -45,26 +45,21 @@ public class ViewExample {
|
|||
}
|
||||
}
|
||||
|
||||
public static class ExampleView extends AbstractView {
|
||||
public static class ExampleView extends AbstractPersistentView {
|
||||
|
||||
private int numReplicated = 0;
|
||||
|
||||
@Override
|
||||
public String viewId() {
|
||||
@Override public String persistenceId() { return "persistentActor-5"; }
|
||||
@Override public String viewId() {
|
||||
return "view-5";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String persistenceId() {
|
||||
return "persistentActor-5";
|
||||
}
|
||||
|
||||
public ExampleView() {
|
||||
receive(ReceiveBuilder.
|
||||
match(Persistent.class, p -> {
|
||||
match(Object.class, m -> isPersistent(), msg -> {
|
||||
numReplicated += 1;
|
||||
System.out.println(String.format("view received %s (num replicated = %d)",
|
||||
p.payload(),
|
||||
msg,
|
||||
numReplicated));
|
||||
}).
|
||||
match(SnapshotOffer.class, so -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue