Giter Site home page Giter Site logo

akka-topics's People

Contributors

franciscolopezsancho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

akka-topics's Issues

I'm reading your book online on Manning.

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.

Chapter03 Logging issue

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.

Is there a java version of this?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.