Hi Mike, expectMsgClass contains a default timeout, maybe that is too short for your actor to do its thing. You could try with the overload of the method that takes a duration to say how long it will take before you consider it as did-not-arrive.
Could this perhaps solve your problem? -- Johan Andrén Typesafe - Reactive apps on the JVM Twitter: @apnylle On Friday, January 8, 2016 at 3:49:11 PM UTC+1, Michael Patel wrote: > > Hi Guys, > > We're using Akka 2.4.1 in one of our Java projects at work and i'm trying > to understand an unusual case which causes our tests infrequently fail when > run as part of our maven multithreaded build. > > Here's a gist which describes what the test is doing > > https://gist.github.com/patelm5/4e4f82e62ccd230a00cf#file-gistfile1-java > > The Actor under test is simply performing a forward in the receive, using > some dynamic property to get an actor selection ( in this case its 74 ). > > > Here's what a successful run logs : > > 14:19:29.863 [main] INFO org.mikeyp.ForwardingActor - started forwarding > actor fowarding from akka://LookupActorTest1/user/lookup-source-74 -> > akka://LookupActorTest1/system/LookupActorTest2-1 > 14:19:30.364 [main] WARN org.mikeyp.LookupActor - Started onReceive > Thread main, Dispatcher is class akka.testkit.CallingThreadDispatcher > 14:19:30.373 [main] WARN org.mikeyp.ForwardingActor - forwarding message > given to me akka://LookupActorTest1/user/lookup-source-74 to actor > akka://LookupActorTest1/system/LookupActorTest2-1, thread main, dispatcher > is akka.testkit.CallingThreadDispatcher@1827a871 > 14:19:30.375 [main] WARN org.mikeyp.AbstractActorTest - Shutting it down > 14:19:30.381 [LookupActorTest1-akka.actor.default-dispatcher-4] INFO > org.mikeyp.ForwardingActor - stopped forwarding actor fowarding from > akka://LookupActorTest1/user/lookup-source-74 -> > akka://LookupActorTest1/system/LookupActorTest2-1 > > Curiously, under certain conditions ( usually a maven multithreaded build > ) the logging output differs slightly and prints > > 10:17:56.918 [main] INFO org.mikeyp.ForwardingActor - started forwarding > actor [akka://ActorTest99/user/lookup-source-74] -> > [akka://ActorTest99/system/ActorTest100-199] > 10:17:56.918 [main] WARN org.mikeyp.LookupActor - Started onReceive > Thread main, Dispatcher is class akka.testkit.CallingThreadDispatcher > [INFO] [01/08/2016 10:17:56.920] > [ActorTest99-akka.actor.default-dispatcher-5] > [akka://ActorTest99/user/lookup-source-74] Message > [org.mikeyp.LookupResponse] from > Actor[akka://ActorTest99/system/ActorTest100-199#1098554928] to > Actor[akka://ActorTest99/user/lookup-source-74] was not delivered. [2] dead > letters encountered. This logging can be turned off or adjusted with > configuration settings 'akka.log-dead-letters' and > 'akka.log-dead-letters-during-shutdown'. > 10:18:00.995 [main] WARN org.mikeyp.AbstractActorTest - Shutting it down > > The dead letter obviously causes the test to fail, but why is there a dead > letter ? > > If the actor had stopped, presumably my log message would have fired in my > forwarding actor. So I suspected that it might be to do with the actor not > being ready to receive messages somehow, despite the preStart method having > already been called. Is there a case where this can happen that i'm not > aware of, reading the documentation suggests this shouldn't be the case ? > I was able to make the build very stable by adding a short wait after > creating the actor, which I suppose I could replace with an ask of some > kind to check it's ready. I'd just like to understand if this is necessary > in the test. > > Cheers, > Mike. > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
