Hi
I have went through the akka documentation where it mentioned the below statement.
All scheduled task will be executed when the
ActorSystemis terminated, i.e. the task may execute before its timeout.
Below is the code I used to test this,
private static List<Cancellable> cancellableList = new ArrayList<>();
public static void main(String args[]) throws Exception {
system = ActorSystem.create("ReactorCluster");
actorA = system.actorOf(Props.create(ActorA.class), "actorA");
Cancellable c = getSystem()
.scheduler()
.scheduleOnce(Duration.ofSeconds(10), actorA, "hi", getSystem().dispatcher(), ActorRef.noSender());
Cancellable c2 = getSystem()
.scheduler()
.scheduleOnce(Duration.ofSeconds(12), actorA, "hello", getSystem().dispatcher(), ActorRef.noSender());
cancellableList.add(c);
cancellableList.add(c2);
system.terminate()
}
Below is createReceive implementation for ActorA
@Override
public Receive createReceive() {
return receiveBuilder()
.matchEquals("hi", h->{
System.out.println("Hi");
})
.matchEquals("hello", hello->{
System.out.println("Hello");
})
.build();
But it is not printing hi and hello message in the console. Kindly guide me on this !!