+act,sam,doc #3940 Added receive setter for Java Lambda actors
* Added a setter for Java lambda actors to "hide" the not so nice looking type signature of the "receive" method. * Updated docs to reflect the changes. * Converted samples to use the new setter.
This commit is contained in:
parent
30ae25a90c
commit
723c931d16
23 changed files with 683 additions and 570 deletions
|
|
@ -61,15 +61,15 @@ class ArithmeticService extends AbstractLoggingActor {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartialFunction<Object, BoxedUnit> receive() {
|
||||
return ReceiveBuilder.
|
||||
ArithmeticService() {
|
||||
receive(ReceiveBuilder.
|
||||
match(Expression.class, expr -> {
|
||||
// We delegate the dangerous task of calculation to a worker, passing the
|
||||
// expression as a constructor argument to the actor.
|
||||
ActorRef worker = context().actorOf(FlakyExpressionCalculator.props(expr, Left));
|
||||
pendingWorkers.put(worker, sender());
|
||||
}).
|
||||
match(Result.class, r -> notifyConsumerSuccess(sender(), r.getValue())).build();
|
||||
match(Result.class, r -> notifyConsumerSuccess(sender(), r.getValue())).build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue