Aggregating Messages using Akka – Part 2

Following on from the last posting, and trying various variants of a solution to terminate the expect function rather than reply on the timeout for the happy path, I ended up with this hacked solution

var count=0


context.children.foreach( f => {count=count+1})

With count, I can now effectively terminate the collector as per the other bloggers solutions

def collectResults(force: Boolean = false) {
   if (results.size == count || force) {
      originalSender ! results.toList // Make sure it becomes immutable


~ by mdavey on January 23, 2014.

Leave a Reply

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

You are commenting using your 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: