Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Error Kernel Pattern #4

Open
He-Pin opened this issue Jan 20, 2016 · 0 comments
Open

The Error Kernel Pattern #4

He-Pin opened this issue Jan 20, 2016 · 0 comments
Labels

Comments

@He-Pin
Copy link
Member

He-Pin commented Jan 20, 2016

该模式也是Akka的核心思想之一,也是Akka的Actor Kernel的由来。该模式的核心思想是:将重要的数据以及消息保留在根(root)上,并将危险的操作通过简历子actor,分配出去,同时监控它们。

一个常见的场景是如何保证一个消息总能被处理而不会因为Actor重启而丢失?这种情况下我们可以通过下面的步骤来应用该模式:

  1. 通过应用单一责任模式将高风险的操作移交到子Actor,并且需要监控子Actor。
  2. 在收到消息后,将任务分配给(创建新的)子Actor来完成。
  3. 子Actor通过Pull模型从父Actor拉取任务。
  4. 任务完成后做对应的ACK。
  5. 在任务失败或者子Actor挂掉后,应用对应的策略,比如重做,丢弃等。

该模式也可以结合kafka的pull 和手动commit以及Akka Persistence使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant