I have the following sequential actions on two actors, a parent P and a child C:
context watch c
)context unwatch c
)c ! PoisonPill
)What I want to know is; am I guaranteed that P does not receive a Terminated
event for C?
Here's a sample piece of code
class HappensBefore extends App {
class C extends Actor { def receive = {} }
class P extends Actor {
val c = context actorOf Props[C]
context watch c
context unwatch c
c ! PoisonPill
def receive = { case Terminated(child) => println("Oh Noes!") }
}
ActorSystem("test") actorOf Props[P]
}
2) postStop() This method is used to release resources after stopping the Actor. It may be used for deregistering this Actor. Messages sent to a stopped actor will be redirected to the deadLetters of the ActorSystem.
Akka actors are asynchronous from the beginning. Reactive programs can be implemented in either way, synchronous and asynchronous.
Start Hook This method is called when the actor is first created.
Akka ensures that each instance of an actor runs in its own lightweight thread and that messages are processed one at a time. In this way, each actor's state can be reliably maintained without the developer needing to explicitly worry about synchronization or race conditions.
No, there is no such guarantee.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With