2
votes

I've been building a data mining app. I use multiple actors to query a data source and then I log incremental changes to text files. However, multiple miners can receive data on the same entity. This leads to race conditions that can lead to duplicate log data and other anomalies in the log files.

To prevent this, I want to add a single Finalizer Actor and use STM. I will have Miner actors that submit entities to the shared memory and send a message to the Finalizer to notify it to process that entity. By having STM, if the entity is updated by another Miner during the Finalizer's transaction, the Finalizer will abort the transaction and start over again. When the Finalizer successfully reads (and deletes, for GC) the entity, it sends a message to the Logger. This way, the Logger actor will not log duplicate entries.

However: http://doc.akka.io/docs/akka/2.4.1/scala/agents.html

Agents participating in enclosing STM transaction is a deprecated feature in 2.3.

If Agents and STM are now deprecated, what is the recommended solution for shared actor state?

1

1 Answers

0
votes

My solution was to ScalaSTM with Actors accessing a singleton/shared TMap.

https://nbronson.github.io/scala-stm/map_snapshots.html