|
Akka/Scala example source code file (CreationActor.java)
The CreationActor.java Akka example source codepackage sample.remote.calculator; import akka.actor.ActorRef; import akka.actor.Props; import akka.actor.UntypedActor; public class CreationActor extends UntypedActor { @Override public void onReceive(Object message) throws Exception { if (message instanceof Op.MathOp) { ActorRef calculator = getContext().actorOf( Props.create(CalculatorActor.class)); calculator.tell(message, getSelf()); } else if (message instanceof Op.MultiplicationResult) { Op.MultiplicationResult result = (Op.MultiplicationResult) message; System.out.printf("Mul result: %d * %d = %d\n", result.getN1(), result.getN2(), result.getResult()); getContext().stop(getSender()); } else if (message instanceof Op.DivisionResult) { Op.DivisionResult result = (Op.DivisionResult) message; System.out.printf("Div result: %.0f / %d = %.2f\n", result.getN1(), result.getN2(), result.getResult()); getContext().stop(getSender()); } else { unhandled(message); } } } Other Akka source code examplesHere is a short list of links related to this Akka CreationActor.java source code file: |
... this post is sponsored by my books ... | |
![]() #1 New Release! |
![]() FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.