Correct way to start ActorSystem with AKKA Java API

I am using Java API for Akka 2.0 and feel that I am not using ActorSystem correctly to start and / or / xor stop TypedActors. When the application is closed, the java process is not terminated. After debugging, I see that the default manager still has multiple threads running and the scheduler is still running. Is there something obvious that I am doing wrong in the example below?

Config akkaConf = ConfigFactory.load();
ActorSystem actorSystem = ActorSystem.create("myApp", akkaConf);

TypedProps<Actor1Impl> actor1TypedProps = new TypedProps<Actor1Impl>(Actor1Interface.class, new Creator<Actor1Impl>(
    public Actor1Impl create() {
        return new Actor1Impl(nonDefault, constructor, scalaIsSo, muchMoreElegant);
    }
);
Actor1Interface a1 = TypedActor.get(actorSystem).typedActorOf(actor1TypedProps, "anA1Actor");

      

Unbeknownst to the readers (and for brevity), the Actor1Impl class implements TypedActor.PreStart and .PostStop. In PreStart, it starts the Runnable task to run periodically. I thought this might keep the Scheduler active, but I also kept the returned Cancellable, which I believe should be canceled in the PostStop block. It didn't help to terminate the Scheduler thread. Anyway, back to history ...

There are also a number of other types of actors, each with a nonStandard constructor. Some of them register periodic Runnables with a scheduler like Actor1Impl above. And to add to the fun, some even require different Actors as constructor arguments so that Actors can register for callbacks, like this:

public Actor2Impl(Actor1Interface a1) {
    a1.registerCallback(TypedActor.<Actor2Interface>self());
}

      

After determining that the application has outlived its usefulness, the following is performed:

TypedActor.get(actorSystem).stop(a1);
TypedActor.get(actorSystem).stop(a2);
...
TypedActor.get(actorSystem).stop(aN);
actorSystem.shutdown();

      

Is there something I am doing that is blatantly wrong that could cause the Java process to terminate? In particular, anything that could cause the default scheduler and dispatcher to be disabled?

+3
java akka


source to share


No one has answered this question yet

Check out similar questions:

1823
What's the easiest way to print a Java array?
935
Eclipse Cannot Start - Java was started but exit code returned = 13
791
What is an efficient way to implement singleton pattern in Java?
596
What's the best way to filter a Java collection?
587
In Java, what is the best way to determine the size of an object?
573
Easiest way to convert list to set in Java
532
Simple way to repeat a string in java
469
Ways to iterate over a list in Java
2
How to disable dispatcher thread in akka ActorSystem
1
Akka cannot start ActorSystem



All Articles
Loading...
X
Show
Funny
Dev
Pics