I'm new to AKKA (java) and I'm trying to implement the following using AKKA:
I receive a bunch of messages from an external process, and each message contains X numbers. I want to perform an operation on each number and then aggregate (sum) the results per message.
For example:
- message1 - 1,3,5 --> doSomething(1)+doSomething(3)+doSomething(5)
- message2 - 5,6 --> doSomething(5)+doSomething(6)
The "doSomething" code should be concurrent as well as the rest of my code, so I want to implement something like the following:
- class Actor1 --> grabs a message from a queue and sends the messages to Actor2
- class Actor2 --> splits the message to it's numbers and sends each "number" message to Actor3.
- class Actor3 --> activates doSomething(number) and returns a result to Actor2.
- class Actor2 --> will aggregate it's related message results (how will it know from where the "number" message cam from?? create a new actor system for that?) and return the aggregated result to Actor1. ...
How can I implement the aggregation using akka for java? I need to store a context. Seems that I have to create a pool of actor systems to make sure that each subgroup (message with numbers) is handled separately.
Any ideas? Is AKKA suitable for aggregated operations (that should be concurrent)?