Akka is a toolkit and runtime for building highly concurrent, distributed, and fault-tolerant event-driven applications on the JVM. Akka can be used with both Java and Scala. This guide introduces Akka by describing the Java version of the Hello World example. If you prefer to use Akka with Scala, switch to the Akka Quickstart with Scala guide.
Actors are the unit of execution in Akka. The Actor model is an abstraction that makes it easier to write correct concurrent, parallel and distributed systems. The Hello World example illustrates Akka basics. Within 30 minutes, you should be able to download and run the example and use this guide to understand how the example is constructed. This will get your feet wet, and hopefully inspire you to dive deeper into the wonderful sea of Akka!
bogon:akka-quickstart-java weikeqin1$ bogon:akka-quickstart-java weikeqin1$ mvn compile exec:exec [INFO] Scanning for projects... Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.pom (10 kB at 15 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar (50 kB at 138 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.pom (13 kB at 65 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.jar Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/exec-maven-plugin/1.6.0/exec-maven-plugin-1.6.0.jar (58 kB at 179 kB/s) [INFO] [INFO] ------------------------< hello-akka-java:app >------------------------- [INFO] Building app 1.0 [INFO] --------------------------------[ jar ]--------------------------------- Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-typed_2.13/2.6.6/akka-actor-typed_2.13-2.6.6.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-typed_2.13/2.6.6/akka-actor-typed_2.13-2.6.6.pom (2.6 kB at 11 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-slf4j_2.13/2.6.6/akka-slf4j_2.13-2.6.6.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-slf4j_2.13/2.6.6/akka-slf4j_2.13-2.6.6.pom (2.9 kB at 7.9 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.6.6/akka-actor-testkit-typed_2.13-2.6.6.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.6.6/akka-actor-testkit-typed_2.13-2.6.6.pom (3.6 kB at 12 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-testkit_2.13/2.6.6/akka-testkit_2.13-2.6.6.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-testkit_2.13/2.6.6/akka-testkit_2.13-2.6.6.pom (3.5 kB at 10 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-typed_2.13/2.6.6/akka-actor-typed_2.13-2.6.6.jar Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-testkit_2.13/2.6.6/akka-testkit_2.13-2.6.6.jar Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.6.6/akka-actor-testkit-typed_2.13-2.6.6.jar Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-slf4j_2.13/2.6.6/akka-slf4j_2.13-2.6.6.jar Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-slf4j_2.13/2.6.6/akka-slf4j_2.13-2.6.6.jar (17 kB at 38 kB/s) Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-testkit_2.13/2.6.6/akka-testkit_2.13-2.6.6.jar (261 kB at 328 kB/s) Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.6.6/akka-actor-testkit-typed_2.13-2.6.6.jar (315 kB at 382 kB/s) Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/typesafe/akka/akka-actor-typed_2.13/2.6.6/akka-actor-typed_2.13-2.6.6.jar (1.2 MB at 1.1 MB/s) [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ app --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ app --- Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.pom (891 B at 3.2 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler/2.7/plexus-compiler-2.7.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler/2.7/plexus-compiler-2.7.pom (4.9 kB at 34 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.pom (711 B at 3.0 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.pom (792 B at 5.3 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compilers/2.7/plexus-compilers-2.7.pom Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compilers/2.7/plexus-compilers-2.7.pom (1.4 kB at 3.1 kB/s) Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.jar Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.jar Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.jar Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.jar (4.7 kB at 30 kB/s) Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.jar (19 kB at 113 kB/s) Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.jar (26 kB at 90 kB/s) [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 4 source files to /Users/weikeqin1/Downloads/akka-quickstart-java/target/classes [INFO] [INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ app --- SLF4J: A number (1) of logging calls during the initialization phase have been intercepted and are SLF4J: now being replayed. These are subject to the filtering rules of the underlying logging system. SLF4J: See also http://www.slf4j.org/codes.html#replay [2020-06-13 22:44:03,567] [INFO] [akka.event.slf4j.Slf4jLogger] [helloakka-akka.actor.default-dispatcher-3] [] - Slf4jLogger started >>> Press ENTER to exit <<< [2020-06-13 22:44:03,660] [INFO] [com.example.Greeter] [helloakka-akka.actor.default-dispatcher-5] [akka://helloakka/user/greeter] - Hello Charles! [2020-06-13 22:44:03,663] [INFO] [com.example.GreeterBot] [helloakka-akka.actor.default-dispatcher-3] [akka://helloakka/user/Charles] - Greeting 1 for Charles [2020-06-13 22:44:03,663] [INFO] [com.example.Greeter] [helloakka-akka.actor.default-dispatcher-5] [akka://helloakka/user/greeter] - Hello Charles! [2020-06-13 22:44:03,663] [INFO] [com.example.GreeterBot] [helloakka-akka.actor.default-dispatcher-3] [akka://helloakka/user/Charles] - Greeting 2 for Charles [2020-06-13 22:44:03,663] [INFO] [com.example.Greeter] [helloakka-akka.actor.default-dispatcher-5] [akka://helloakka/user/greeter] - Hello Charles! [2020-06-13 22:44:03,664] [INFO] [com.example.GreeterBot] [helloakka-akka.actor.default-dispatcher-5] [akka://helloakka/user/Charles] - Greeting 3 for Charles
Exception in thread "main" java.lang.IllegalArgumentException: Actor class [cn.wkq.java.akka.AkkaDemo$HelloActor] must be subClass of akka.actor.Actor or akka.actor.IndirectActorProducer. at akka.actor.AbstractProps.validate(AbstractProps.scala:31)