java.lang.IllegalStateException: cannot create children while terminating or terminated.

۹۴۱ بازدید
رفتن به اولین پیام خوانده‌نشده

ccirim

خوانده‌نشده،
۳ تیر ۱۳۹۴، ۱۰:۰۳:۰۴۱۳۹۴/۴/۳
به akka...@googlegroups.com
Hi to all

Recently I have this error during application run:

ERR;1447360171;1258130494;APPLICATION;Service.execute;03/06/2015 09:37:37,271;ERROR Service: cannot create children while terminating or terminated
java.lang.IllegalStateException: cannot create children while terminating or terminated
    at akka.actor.dungeon.Children$class.makeChild(Children.scala:200)
    at akka.actor.dungeon.Children$class.attachChild(Children.scala:42)
    at akka.actor.ActorCell.attachChild(ActorCell.scala:369)
    at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:552)
    
Generally happens after AskTimeoutException and after this error I have to restart application server.

Why (I never call shutdown actorSystem)?

I try to solve the problem, but I dont know if this "patch" work correctly:

-----------------------------------------------------------------------------------------------------------------------------

Object result = null;

try{

...
    
    ActorRef masterActor = null;
        try{
            masterActor = myActorSystem.actorOf(SpringExtProvider.get(myActorSystem).props("MasterActor").withRouter(new SmallestMailboxPool(4)), getMasterName(val1, val, val3));
        }
        catch(IllegalStateException ex){
            log.error("ACTOR SYSTEM IS TERMINATING: " + ex.getMessage());
            myActorSystem.awaitTermination();
            log.info("TRYING AGAIN...");
            try{
                masterActor = myActorSystem.actorOf(SpringExtProvider.get(myActorSystem).props("MasterActor").withRouter(new SmallestMailboxPool(4)), getMasterName(val1, val, val3));
            }
            catch(IllegalStateException ex1){
                log.error("NOTHING TO DO: " + ex.getMessage());
                throw ex1;
            }
        }
    
    Future<Object> future = Patterns.ask(masterActor, inputMessage, timeout);
    result = Await.result(future, timeout.duration());
...

}
catch(RuntimeException e){
    e.printStackTrace();
    ...
}
catch(Exception e){
    e.printStackTrace();
    ...
}
    
return result;

-----------------------------------------------------------------------------------------------------------------------------

My application apply "PER REQUEST ACTOR" pattern (http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/)
http://techblog.net-a-porter.com/wp-content/uploads/2013/12/tell1.png
http://techblog.net-a-porter.com/wp-content/uploads/2013/12/tell2.png

masterActor == perRequest

I have only one ask method, at start point, to wait collection of actor's results to respond to my calling service.

Thanks to all!
پاسخ به همه
پاسخ به نویسنده
فرستادن
0 پیام جدید