mardi 7 février 2017

how to monitor the death of child actor that gets spawned

I have the following parent - child relationship

public class ParentActor extends UntypedActor {

    @Override
    public void onReceive(Object msg) throws Exception {

        if (msg instanceof Command) {
            final String data = ((Command) msg).getData();
            final Event event = new Event(data, UUID.randomUUID().toString());
ActorRef childActor = getContext().actorOf(Props.create(ChildActor.class), "child-actor");

            childActor.tell(event, getSelf());
        } else if (msg.equals("echo")) {
            log.info("ECHO!");
        }
    }
}
public class ChildActor extends UntypedActor {

    @Override
    public void onReceive(Object msg) {
        log.info("Received Event: " + msg);
        //PoisonPill and kill self
    }


}

How do I write a test that watches and verfies that the child actor dies after sending message to parent?

Aucun commentaire:

Enregistrer un commentaire