franciscolopezsancho / akka-topics Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
By your attention in discuss of Lightbend, I find your book Akka in Aciton (2nd Edtion) is pre-released. Congratulation! I read some chapters online on Manning. It's a great job!
I find that the Cargo example in your book is like the ShoppingCart of Akka guide. This's my problem. Why is the count of either the cargo container or shopping cart limited? Your container-tag is limited to 3, and the ShoppingCart is limited to 5. I think there are lots of entites in the production environment. One tag should be for one entity at write side. Therefore, one tag is for one projection at read side.
I post my confusion to the discuss of Lightbend, but nobody replies yet. Would you mind to help me?
Thank you.
I seem to be having trouble getting the unhappy
path to log an error for the simplequestion
exercise in Chapter03.
In an effort to help it timeout & see similar logging to the unhappy
path shared in the book
[Worker $] - worker-text-a: DONE!
[Manager$] - text-a read by worker-text-a
[Worker $] - worker-text-b: DONE!
[Manager$] - text-b read by worker-text-b
[Manager$] - parsing text-c' has failed with [Ask timed out on
[Actor[akka://example-ask-without-content/user/manager-1/
worker-text-c#-1664156553]] after [3000 ms]. Message of type
[ask.simple.Worker$Parse]. A typical reason for
`AskTimeoutException` is that the recipient actor
didn't send a reply.
[Worker $] - worker-text-c: DONE!
[DeadLetterActorRef] - Message [ask.simple.Worker$Done$]
to Actor[akka://example-ask-without-content/deadLetters]
was not delivered. [1] dead letters encountered. If this is
not an expected behavior then
Actor[akka://example-ask-without-content/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'.
I reduced the Timeout
within the Manager.setup
& added some logging. I also reduced the random range for the Random.between
& printed out from within fakeLengthyParse
to try better understand why it is not working. I tried to create a branch to share but don't have access, here is the patch
diff --git a/chapter03/src/main/scala/simplequestion/Manager.scala b/chapter03/src/main/scala/simplequestion/Manager.scala
index 97ecb35..8659ed3 100644
--- a/chapter03/src/main/scala/simplequestion/Manager.scala
+++ b/chapter03/src/main/scala/simplequestion/Manager.scala
@@ -17,7 +17,9 @@ object Manager {
def apply(): Behavior[Command] =
Behaviors.setup { context =>
- implicit val timeout: Timeout = Timeout(3, SECONDS)
+ implicit val timeout: Timeout = Timeout(1, SECONDS)
+ context.log.info(
+ s"Logging info from Manager with timeout: $timeout")
Behaviors.receiveMessage { message =>
message match {
diff --git a/chapter03/src/main/scala/simplequestion/Worker.scala b/chapter03/src/main/scala/simplequestion/Worker.scala
index 87e967e..3c3c056 100644
--- a/chapter03/src/main/scala/simplequestion/Worker.scala
+++ b/chapter03/src/main/scala/simplequestion/Worker.scala
@@ -27,8 +27,10 @@ object Worker {
}
private def fakeLengthyParsing(text: String): Unit = {
- val endTime =
- System.currentTimeMillis + Random.between(2000, 4000)
+ val random = Random.between(1000, 1500) // will always exceed 1 SECOND timeout
+ val endTime = System.currentTimeMillis + random
+ println(
+ s"Logging the random value ($random) & the associated text ($text)")
while (endTime > System.currentTimeMillis) {}
}
}
Here is some sample logs after my changes
[info] running simplequestion.SimpleQuestionApp
press ENTER to terminate
2023-10-17 10:19:35,450 INFO [Manager$] - Logging info from Manager with timeout: Timeout(1 second)
Logging the random value (1488) & the associated text (text-a)
Logging the random value (1265) & the associated text (text-b)
Logging the random value (1234) & the associated text (text-c)
2023-10-17 10:19:35,452 INFO [CoordinatedShutdown] - Running CoordinatedShutdown with reason [ActorSystemTerminateReason]
[success] Total time: 2 s, completed 17 Oct 2023, 10:19:35
[IJ]2023-10-17 10:19:36,686 INFO [Worker$] - worker-text-c: done
2023-10-17 10:19:36,717 INFO [Worker$] - worker-text-b: done
2023-10-17 10:19:36,939 INFO [Worker$] - worker-text-a: done
I have tried a few attempts but still cannot get it to log an error & kill the proxy intermediate actor between the Worker
& the Manager
- so thought this would be the best way to reach you. Apologies if not, I am new to this.
Thanks for putting up these akka examples on GitHub and linking to this repo from https://www.manning.com/books/akka-in-action-second-edition. The presence of a Github repository for a book is always a great plus!
The first edition of the "Akka in Action" book repository https://github.com/RayRoestenburg/akka-in-action has a LICENSE file and it would be awesome if you can also add a license to this repo too.
New developer and new to Akka as well (also great book so far). I was hoping If there is a java version of this code. I only see scala. If not I could begin working on one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.