码迷,mamicode.com
首页 > 其他好文 > 详细

Akka Stop Kill PoisonPill 区别

时间:2017-06-20 10:57:16      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:more   received   one   card   rmi   orm   call   and   dex   

Both stop and PoisonPill will terminate the actor and stop the message queue. They will cause the actor to cease processing messages, send a stop call to all its children, wait for them to terminate, then call its postStop hook. All further messages are sent to the dead letters mailbox.

The difference is in which messages get processed before this sequence starts. In the case of the stop call, the message currently being processed is completed first, with all others discarded. When sending a PoisonPill, this is simply another message in the queue, so the sequence will start when the PoisonPill is received. All messages that are ahead of it in the queue will be processed first.

By contrast, the Kill message causes the actor to throw an ActorKilledException which gets handled using the normal supervisor mechanism. So the behaviour here depends on what you‘ve defined in your supervisor strategy. The default is to stop the actor. But the mailbox persists, so when the actor restarts it will still have the old messages except for the one that caused the failure.

Also see the ‘Stopping an Actor‘, ‘Killing an Actor‘ section in the docs:

http://doc.akka.io/docs/akka/snapshot/scala/actors.html

And more on supervision strategies:

http://doc.akka.io/docs/akka/snapshot/scala/fault-tolerance.html

Akka Stop Kill PoisonPill 区别

标签:more   received   one   card   rmi   orm   call   and   dex   

原文地址:http://www.cnblogs.com/yunfeiqi/p/7052843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!