question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PersistenceLifecycleEvent not sent to typed actor

See original GitHub issue

Hi! Is there a way to hook in to PersistenceLifecycleEvent in typed actors? I’ve looked at https://github.com/Horusiath/Akkling/issues/72 and the test, but this seems only to work for untyped actors. Here is a fork with the same test for a typed actor (Eventsourced<string>), and it currently fails: https://github.com/Yakimych/Akkling/commit/c9dc995e6479f952d2cda973b4c6b2808318b42b

My guess is that typed actors don’t receive messages of anything but the specified type, so I am wondering if this is possible at all.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Horusiathcommented, Jan 18, 2021

I think the reason here is that your persistence provider uses some configuration of JSON.NET, that doesn’t support type name handling. There are two problems:

  1. Without type name handling, JSON.NET serializer won’t know what object should it deserialize when serializer.DeserializeObject<obj> is called.
  2. With type name handling turned on, a fully qualified type name is used. So if you ever change the type name or namespace in the future, it won’t be able to deserialize it back.

Usually when it comes to persistent serialization, I suggest people to write their own custom serializers (using eg. protobuf, FsPickler or whatever you want), to have full control of binary format and how it changes over time.

1reaction
Horusiathcommented, Jan 17, 2021

From what I see, you’re using Json.NET for persistence - this may be the reason, when trying to deserialize json payload into obj it doesn’t know what specific type of object do you want - which in this case it will default to JDocument or JObject.

This is continuous problem of using JSON.NET, and one of the reasons why we started using Hyperion - but problem with Hyperion is that it’s binary format is not stabilized and it doesn’t provide any guarantees, that future version will keep it backwards compatible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Classic Persistence - Documentation - Akka
Successfully persisted events are internally sent back to the persistent actor as individual messages that trigger event handler executions.
Read more >
How to mock actors in a cluster sharding test environment?
Let's assume persistent actor/event sourced behavior of type EntityA will create and interact with another persistent actor/event sourced ...
Read more >
Persistence failure when replaying events for persistenceId ...
Akka.Cluster.Sharding.PersistentShardCoordinator throws exception when replaying the events. It can connect to the database and create all ...
Read more >
Viewing Akka Persistence data stored in Cassandra (Part 2)
When the actor is restarted, in the initialization process, receiveRecover will be called repeatedly with the events.² With each event the state ...
Read more >
Event Sourcing · Apache Pekko Documentation
An event sourced actor (also known as a persistent actor) receives a (non-persistent) command which is first validated if it can be applied...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found