Hi,
what would be a proper way to model a long-living worker with akka? I have two persistent actors polling a database, for inserts and updates, each with a hard-coded unique persistence id. The intention is to have exactly one of both at any time. The persistent state represents the polling offset.
The actors are supervised with restartWithBackoff
strategy. Also the actors are reacting to the PreRestart
signal by closing the database connection.
My problem is that if an actor crashes, the new instance is not created with following warning:
{“level”:“WARN”,“logger”:“akka.persistence.cassandra.journal.TagWriters”,“message”:“Persistent actor starting for pid [UpdatesPollingCommand|UpdatesPollingCommand]. Old ref hasn’t terminated yet: [Actor[akka://Shipments/system/sharding/UpdatesPollingCommand/0/UpdatesPollingCommand#-1167587395]]. Persistent Actors with the same PersistenceId should not run concurrently”}
I’ve created a gist representing the important parts of my design here: actors.scala · GitHub
I’d be very thankful for any suggestions if something is wrong with my design/approach or with the code…