Aggregating Messages using Akka – Trait and actorSelection


Whilst on the plane back from NY recently I began to ponder about the aggregation pattern and akka.  Luckily, it would appear that Jamie Allen, followed by a few other bloggers have a solution that is well documented – the aggregator trait.

So, if I use the actorSelection to fire off messages to a group of identical actors e.g. algo’s or some such thing;


context.actorSelection("../<Parent>/*") ! <message>

I need to use the expect rather than the expectOnce to process the replies


context.actorSelection("../<Parent>/*") ! <message>

expect {

case <response> =>

...

collectAllResponse()

}

In the Akka aggregator pattern documentation, there is a results.size check to known when you have all the response messages (or timeout), since you originally knew how many you had sent.  How do I know how many messages the actorSelection sent?

~ by mdavey on January 22, 2014.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: