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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -