Srinivas K
Srinivas K

Reputation: 11

akka - Java stateful actor persistence

I am developing an application using AKKA (Java API). I have a few questions:

  1. In an actor class, is it okay to have a few data structures (Example: HashMap) as part of the actor state (attributes of the class)?

  2. If the actor dies, actor will be restarted by the SUpervisory actor. However, I am wondering how to restore the contents of these data structures. Please suggest?

Initially, I thought of using Cassandra to persist the data as and when this actor receives messages to save the member objects to Cassandra. Not sure if this is the right approach. Please help

Thank you, KS

Upvotes: 1

Views: 892

Answers (2)

Derek Organ
Derek Organ

Reputation: 8473

One possible option is keep it in data related to actors in Redis similar to how you can create a durable mailbox. In what situation is your actor dying?

Upvotes: 0

Viktor Klang
Viktor Klang

Reputation: 26579

Have a child actor that performs any and all risky operations, and have your actor's supervisor strategy set up to fit your needs for that child.

Upvotes: 2

Related Questions