I am currently modeling a PersistentFSM actor and humbly ask for guidance.
Suppose, we write a name to a database in the state "InProcess". Having
successfully committed to the database, we would like the state machine to
change its state to "Closed".
What if we manage to write to the database, but the actor crashes before
getting notified or before it manages to update its state?
Please look at the following code:
sealed abstract class State
case object InProcess extends State
case object Closed extends State
case class Commit(val name:String)
case class Committed(val name: String)
class DatabaseActor extends Actor {
def receive = {
case Commit(name) =>
//Write to database......
//......
sender ! Committed(name)
case _ => //"received unknown message")
}
}
//Sorry, I am using old API
abstract class TransactionIssue extends PersistentFsmActor[State, Any, Any]
with Actor {
startWith(InProcess, EmptyIssueData)
when(InProcess) {
case Event(commit: Commit, _) =>
val databaseActor = context.actorOf(Props[DatabaseActor],
"DatabaseActor")
databaseActor ! commit
stay
case Event(commit: Committed, _) =>
goto(Closed)
}
initialize
}
In advance, thank you very much.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.