Home How to store state in an Actor
Reply: 0

How to store state in an Actor

user1045
1#
user1045 Published in July 17, 2018, 12:01 am

I am using the AKKA framework for concurrency with Java and have the following use case

The actors operate on a graph data structure and work on each node in the graph in a specific order and do not proceed to the next until a node is processed

Here is the relevant code

GraphProcessor:
if (msg instanceof processGraph) {

      // For each level in the graph create a child at each level, for nodes on the same level create child actors simultaneously

      BreadthFirstIterator bfs = new BreadthFirstIterator<>(graph);
        while (bfs.hasNext()) {
          ActorRef NodeProcesor = getContext().actorOf(NodeProcesor.props());
             NodeProcesor.tell(send the node),
                       getSelf());

     }

    }
  }

Now the question is, while the nodes of one graph are getting processed a new graph may be handed over to the GraphProcessor, this will confuse the actor from tracking the state of the graph? How do I correctly maintain this informtaion?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312313 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO