score:0

Try adding this code after send the message:

Boolean wasProcessed = (Integer)Await.result(Patterns.ask(communicator, new ResultClass(), 5000), 
            Duration.create(5000, TimeUnit.MILLISECONDS));

if(wasProcessed){
    actorSystem.shutdown();
}

You also have to add this in your Actor class:

private boolean wasProcessed = false;

@Override
public void onReceive(Object messageReceived) throws Exception {
    if (messageReceived instanceof ResultClass) {
        this.workerActor1.tell(wasProcessed, getSender());
    } else {
        //Put your process code here
        wasProcessed = true;
    }
}

But I recommend you configure a prudential timeout and after that always shutdown the system.


Related Query

More Query from same tag