Java Aggregator for Akka -


i trying implement java aggregator akka, since doesn't like java api supports them (why not!?)

here's best attempt far:

// groovy pseudo-code abstract class aggregator<t> extends untypedactor {     actorref recipient     set<t> aggregation     // todo: timer timer (?)      abstract boolean isaggregated()      @override     void onreceive(object message) {         aggregation << message t          if(isaggregated()) {             recipient.tell(new aggregation(aggregation))    // again, pseudo-code             aggregation.clear()             // todo: timer.reset()         }     } } 

what missing kind of timer construct time aggregator out after, say, 60 seconds if has not aggregated yet. on timeout, should throw exception of sort. on aggregation, timer should reset. ideas how this?

what looking receivetimeout. akka provides feature have timeout when particular actor has not received in predefined amount of time.

in java inside actor:

getcontext().setreceivetimeout(duration.create("1 second")); 

when trigger sends message of type receivetimeout actor , can decide want (exceptions, logging, resetting...).

you can find more information here under section 'receive timeout': http://doc.akka.io/docs/akka/snapshot/java/untyped-actors.html

on other hand, there open-source libraries these kind of things available in github. take https://github.com/sksamuel/akka-patterns more examples.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -