From 7853553f55c8ddd749a69f8c8e8185f0db1dc3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Thu, 19 Sep 2019 12:02:58 +0200 Subject: [PATCH] Extra caveat around state in Java EventSourcedBehavior (#27706) --- akka-docs/src/main/paradox/typed/persistence.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/akka-docs/src/main/paradox/typed/persistence.md b/akka-docs/src/main/paradox/typed/persistence.md index 690d239e39..f891476c01 100644 --- a/akka-docs/src/main/paradox/typed/persistence.md +++ b/akka-docs/src/main/paradox/typed/persistence.md @@ -39,7 +39,6 @@ Java The first important thing to notice is the `Behavior` of a persistent actor is typed to the type of the `Command` because this is the type of message a persistent actor should receive. In Akka Typed this is now enforced by the type system. -The event and state are only used internally. The components that make up a EventSourcedBehavior are: @@ -48,6 +47,15 @@ The components that make up a EventSourcedBehavior are: * `commandHandler` defines how to handle command by producing Effects e.g. persisting events, stopping the persistent actor. * `eventHandler` returns the new state given the current state when an event has been persisted. +@@@ div { .group-java } + +Note that the concrete class does not contain any fields with state like a regular POJO. All state of the +`EventSourcedBehavior` must be represented in the `State` or else they will not be persisted and therefore be +lost when the actor is stopped or restarted. Updates to the State are always performed in the eventHandler +based on the events. + +@@@ + Next we'll discuss each of these in detail. ### Command handler