|
Akka/Scala example source code file (StatsWorker.java)
The StatsWorker.java Akka example source codepackage sample.cluster.stats; import java.util.HashMap; import java.util.Map; import akka.actor.UntypedActor; //#worker public class StatsWorker extends UntypedActor { Map<String, Integer> cache = new HashMap<String, Integer>(); @Override public void onReceive(Object message) { if (message instanceof String) { String word = (String) message; Integer length = cache.get(word); if (length == null) { length = word.length(); cache.put(word, length); } getSender().tell(length, getSelf()); } else { unhandled(message); } } } //#worker Other Akka source code examplesHere is a short list of links related to this Akka StatsWorker.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.