Merged
Conversation
* by storing additional change events when Durable State is updated and deleted we make it possible to use all nice event sourced Projection capabilities with Durable State, including Projections over gRPC * otherwise we would have to duplicate many many things to use the existing DurableStateChange and the queries based on that * we might even deprecate the existing DurableStateChange if this works out, but that can be a later decision
patriknw
commented
Dec 8, 2023
| behavior | ||
|
|
||
| case callback: Callback[_] => | ||
| case callback: Callback[Any] @unchecked => |
Contributor
Author
There was a problem hiding this comment.
This is a weird bug that we haven't noticed before. In the new test this fails when using:
Effect.delete().thenReply(replyTo)((_: String) => Done)
No compilation errors, but actually some red squiggles in IntelliJ. The runtime error was:
java.lang.ClassCastException: class java.lang.String cannot be cast to class scala.runtime.Nothing$ (java.lang.String is in module java.base of loader 'bootstrap'; scala.runtime.Nothing$ is in unnamed module of loader 'app')
at akka.persistence.typed.state.internal.ReplyEffectImpl$$anonfun$$lessinit$greater$1.apply(SideEffect.scala:32)
at akka.persistence.typed.state.internal.ReplyEffectImpl$$anonfun$$lessinit$greater$1.apply(SideEffect.scala:32)
at akka.persistence.typed.state.internal.Running.applySideEffect(Running.scala:381)
at akka.persistence.typed.state.internal.Running.applySideEffects(Running.scala:359)
at akka.persistence.typed.state.internal.Running$PersistingState.onDeleteSuccess(Running.scala:283)
at akka.persistence.typed.state.internal.Running$PersistingState.onMessage(Running.scala:236)
at akka.persistence.typed.state.internal.Running$PersistingState.onMessage(Running.scala:222)
at akka.actor.typed.scaladsl.AbstractBehavior.receive(AbstractBehavior.scala:84)
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
at akka.persistence.typed.state.internal.DurableStateBehaviorImpl$$anon$1.aroundReceive(DurableStateBehaviorImpl.scala:144)
at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
at akka.actor.typed.internal.InterceptorImpl$$anon$2.apply(InterceptorImpl.scala:57)
at akka.actor.typed.internal.SimpleSupervisor.aroundReceive(Supervision.scala:132)
at akka.actor.typed.internal.InterceptorImpl.receive(InterceptorImpl.scala:85)
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
at akka.actor.typed.internal.adapter.ActorAdapter.$anonfun$aroundReceive$2(ActorAdapter.scala:101)
at akka.actor.typed.internal.adapter.ActorAdapter.$anonfun$aroundReceive$2$adapted(ActorAdapter.scala:97)
at akka.actor.typed.internal.adapter.ActorAdapter.withSafelyAdapted(ActorAdapter.scala:204)
at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:97)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
at akka.actor.ActorCell.invoke(ActorCell.scala:547)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Same fix in EventSourcedBehavior.
patriknw
commented
Dec 8, 2023
...nce-typed/src/test/java/jdocs/akka/persistence/typed/DurableStatePersistentBehaviorTest.java
Outdated
Show resolved
Hide resolved
dd4dc76 to
22d5bf5
Compare
patriknw
commented
Dec 11, 2023
...istence-typed/src/main/scala/akka/persistence/typed/state/javadsl/DurableStateBehavior.scala
Outdated
Show resolved
Hide resolved
22d5bf5 to
ca4a7ad
Compare
Contributor
Author
|
This is ready for final review. Regarding reference docs, I added plugin api sections as we had for the state store, but I will add usage docs of the change event handler in Akka Projections docs since that is the purpose. |
johanandren
approved these changes
Dec 12, 2023
| behavior | ||
|
|
||
| case callback: Callback[_] => | ||
| case callback: Callback[Any] @unchecked => |
Contributor
There was a problem hiding this comment.
Unchecked any is the best any.
| if (changeEventHandler.isDefined && !durableStateStore.isInstanceOf[DurableStateUpdateWithChangeEventStore[_]]) | ||
| new IllegalArgumentException( | ||
| "Change event handler was defined but the DurableStateStore " + | ||
| s"[${durableStateStore.getClass.getName}] doesn't implement [DurableStateUpdateWithChangeEventStore]") |
patriknw
commented
Dec 12, 2023
| * The `updateHandler` and `deleteHandler` are invoked after the ordinary command handler. Be aware of that | ||
| * if the state is mutable and modified by the command handler the previous state parameter of the `updateHandler` | ||
| * will also include the modification, since it's the same instance. If that is problem you need to use | ||
| * immutable state and create a new state instance when modifying it in the command handler. |
Contributor
Author
There was a problem hiding this comment.
added this caveat about mutable state
johanandren
approved these changes
Dec 12, 2023
...rsistence-typed/src/main/scala/akka/persistence/typed/state/javadsl/ChangeEventHandler.scala
Outdated
Show resolved
Hide resolved
| * The `updateHandler` and `deleteHandler` are invoked after the ordinary command handler. Be aware of that | ||
| * if the state is mutable and modified by the command handler the previous state parameter of the `updateHandler` | ||
| * will also include the modification, since it's the same instance. If that is problem you need to use | ||
| * immutable state and create a new state instance when modifying it in the command handler. |
...sistence-typed/src/main/scala/akka/persistence/typed/state/scaladsl/ChangeEventHandler.scala
Outdated
Show resolved
Hide resolved
Co-authored-by: Johan Andrén <johan@markatta.com>
johanandren
approved these changes
Dec 14, 2023
He-Pin
pushed a commit
to He-Pin/akka
that referenced
this pull request
Jan 7, 2024
* by storing additional change events when Durable State is updated and deleted we make it possible to use all nice event sourced Projection capabilities with Durable State, including Projections over gRPC * otherwise we would have to duplicate many many things to use the existing DurableStateChange and the queries based on that * we might even deprecate the existing DurableStateChange if this works out, but that can be a later decision * ApiMayChange * reference docs for plugin api * note about mutable state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODO: