Book Effective Akka ⬆
Directory effective-akka\ contains Akka code examples from Allen's book Effective Akka (O'Reilly, 2013).
|
Code examples presented below can be built/run with the following tools:
Build tool | Build file | Parent file | Environment(s) |
---|---|---|---|
ant.bat |
build.xml |
build.xml |
Any a) |
gradle.bat |
build.gradle |
common.gradle |
Any |
make.exe |
Makefile |
Makefile.inc |
Any |
mvn.cmd |
pom.xml |
pom.xml |
Any |
sbt.bat |
build.sbt |
Any | |
cmd.exe |
build.bat |
Windows only | |
bash.exe |
build.sh |
Any |
a) Here "Any" means "tested on Windows, Cygwin, MSYS2 and UNIX".
Example ExtraPattern
is the same Akka application written in Scala.
It has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | build.bat | build.gradle | build.sbt | build.sh | build.xml | gradle.properties | Makefile | pom.xml +---project | build.properties \---src +---main | +---resources | | application.conf | | logback.xml | \---scala | \---org | \---jamieallen | \---effectiveakka | | ExtraPattern.scala | +---common | | Common.scala | \---pattern | \---extra | AccountBalanceRetriever.scala | CheckingAccountsActor.scala | MoneyMarketAccountsActor.scala | SavingsAccountsActor.scala \---test \---scala \---org \---jamieallen \---effectiveakka \---pattern \---extra ExtraSpec.scala ProxyStubs.scala
Batch file build.bat
matches what the user would run from the command prompt (use option -debug
to see the execution details):
> build -verbose run Compile 6 Scala source files to directory "target\classes" [ExtraPattern-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started CheckingAccounts : Received GetCustomerAccountBalances for ID: 1 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 1 SavingsAccounts : Received GetCustomerAccountBalances for ID: 1 CheckingAccounts : Received GetCustomerAccountBalances for ID: 2 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 2 SavingsAccounts : Received GetCustomerAccountBalances for ID: 2 >>> Press ENTER to exit <<< [ExtraPattern-akka.actor.default-dispatcher-7] INFO akka.actor.CoordinatedShutdown - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
Bash script build.sh
works in the same way from a Bash shell prompt :
> sh build.sh -verbose run Compile 6 Scala source files to directory "target/classes" Execute Scala main class "org.jamieallen.effectiveakka.ExtraPattern" CheckingAccounts : Received GetCustomerAccountBalances for ID: 2 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 1 SavingsAccounts : Received GetCustomerAccountBalances for ID: 1 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 2 CheckingAccounts : Received GetCustomerAccountBalances for ID: 1 SavingsAccounts : Received GetCustomerAccountBalances for ID: 2 [INFO] [akkaDeadLetter][02/09/2023 21:16:47.622] [ExtraPattern-akka.actor.default-dispatcher-7] [akka://ExtraPattern/deadLetters] Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://ExtraPattern/user/extra-retriever/$b#1994845275] to Actor[akka://ExtraPattern/deadLetters] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://ExtraPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [INFO] [akkaDeadLetter][02/09/2023 21:16:47.622] [ExtraPattern-akka.actor.default-dispatcher-7] [akka://ExtraPattern/deadLetters] Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://ExtraPattern/user/extra-retriever/$a#1147423554] to Actor[akka://ExtraPattern/deadLetters] was not delivered. [2] dead letters encountered. If this is not an expected behavior then Actor[akka://ExtraPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. >>> Press ENTER to exit <<< [INFO] [02/09/2023 21:16:50.363] [main] [CoordinatedShutdown(akka://ExtraPattern)] Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
CameoPattern
Example ▴
Batch file build.bat
matches what the user would run from the command prompt (use option -debug
to see the execution details):
> build -verbose run Compile 7 Scala source files to directory "target\classes" Execute Scala main class "org.jamieallen.effectiveakka.CameoPattern" [CameoPattern-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started SavingsAccounts : Received GetCustomerAccountBalances for ID: 1 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 1 CheckingAccounts : Received GetCustomerAccountBalances for ID: 1 SavingsAccounts : Received GetCustomerAccountBalances for ID: 2 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 2 CheckingAccounts : Received GetCustomerAccountBalances for ID: 2 [CameoPattern-akka.actor.default-dispatcher-10] INFO akka.actor.DeadLetterActorRef - akkaDeadLetter Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://CameoPattern/user/extra-retriever/cameo-message-handler-1#-946328889] to Actor[akka://CameoPattern/deadLetters] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://CameoPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [CameoPattern-akka.actor.default-dispatcher-10] INFO akka.actor.DeadLetterActorRef - akkaDeadLetter Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://CameoPattern/user/extra-retriever/cameo-message-handler-2#162633198] to Actor[akka://CameoPattern/deadLetters] was not delivered. [2] dead letters encountered. If this is not an expected behavior then Actor[akka://CameoPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. >>> Press ENTER to exit <<< [CameoPattern-akka.actor.default-dispatcher-10] INFO akka.actor.CoordinatedShutdown - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
Bash script build.sh
works in the same way from a Bash shell prompt :
> sh build.sh -verbose run Compile 7 Scala source files to directory "target/classes" Execute Scala main class "org.jamieallen.effectiveakka.CameoPattern" SavingsAccounts : Received GetCustomerAccountBalances for ID: 1 CheckingAccounts : Received GetCustomerAccountBalances for ID: 1 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 1 CheckingAccounts : Received GetCustomerAccountBalances for ID: 2 SavingsAccounts : Received GetCustomerAccountBalances for ID: 2 MoneyMarketAccounts: Received GetCustomerAccountBalances for ID: 2 [INFO] [akkaDeadLetter][02/09/2023 20:59:36.085] [CameoPattern-akka.actor.default-dispatcher-9] [akka://CameoPattern/deadLetters] Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://CameoPattern/user/extra-retriever/cameo-message-handler-2#900144580] to Actor[akka://CameoPattern/deadLetters] was not delivered. [1] dead letters encountered. If this is not an expected behavior then Actor[akka://CameoPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. [INFO] [akkaDeadLetter][02/09/2023 20:59:36.085] [CameoPattern-akka.actor.default-dispatcher-9] [akka://CameoPattern/deadLetters] Message [org.jamieallen.effectiveakka.common.AccountBalances] from Actor[akka://CameoPattern/user/extra-retriever/cameo-message-handler-1#-203518532] to Actor[akka://CameoPattern/deadLetters] was not delivered. [2] dead letters encountered. If this is not an expected behavior then Actor[akka://CameoPattern/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'. >>> Press ENTER to exit <<< [INFO] [02/09/2023 20:59:44.364] [main] [CoordinatedShutdown(akka://CameoPattern)] Running CoordinatedShutdown with reason [ActorSystemTerminateReason]