hi,
Now I want to use reactor to perform concurrent tasks, and send the aggregated result to client.
for example,
1. Client sends the request f = f(1) + f(2) + f(3) + f(4) + ... f(N)
2. When the server receives the request, it(master thread) will split it to multiple tasks
3. Then send tasks to parallel handlers (worker thread)
4. after worker thread calculates the result, and return the result to master.
5. master collects all of results, and replies the aggregated result to client.
I know all of above action can be performed at Akka, but I prefer to use reactor framework since it can be more convenient to integrate with spring.
Could anybody give some example to perform parallel tasks with reactor framework?
thanks.
the following is just some example of akka:
final ActorSystem system = ActorSystem.create("MsgFwd");
final ArrayList<Future<Object>> futures = new ArrayList<Future<Object>>();
Timeout timeout = new Timeout(Duration.create(5, "seconds"));
for (int i = 0; i < 10; i++) {
Future<Object> future = future(new Worker("EventObject"),
system.dispatcher());
futures.add(future);
}
final Future<Iterable<Object>> futureSeq = Futures.sequence(futures,
system.dispatcher());
Iterable<Object> results = Await.result(futureSeq, timeout.duration())