Akka 中 PersistentView 的典型用例是什么?
What is a typical use-case for PersistentView in Akka?
这里http://doc.akka.io/docs/akka/current/scala/persistence.html写成:
PersistentView: A view is a persistent, stateful actor that receives
journaled messages that have been written by another persistent actor.
A view itself does not journal new messages, instead, it updates
internal state only from a persistent actor's replicated message
stream.
PersistentView 的典型用例是什么?
它与 Akka Streams / RX 有何不同?
跟我长得很像
如果您基于 CQRS 设计应用程序,您可能会发现它很有用。 CQRS 非常适合事件源 系统,如博客 post.
中所示
虽然您可能会使用 PersistentActor
actor 来更新应用程序的状态 - 这是命令端/模型,但当您想要显示数据时,PersistentView
actor 会派上用场,依此类推查询端。
一个例子是存储有关银行账户的数据。在传统模型中,您可能会在某个存储库下进行所有 CRUD 操作。此模型中的一个真正基本的转换是对 CUD 位使用 PersistentActor
,对 R 位使用 PersistentView
。好处是您将更新状态的命令部分与查询端分离。
至于最后一个问题,akka-persistence
和akka-streams
的目的不同。事实上 akka-persistence-query-experimental
实际上是使用 akka-streams
构建的,以提供不同的来源。一个例子实际上是here。请注意,PersistentView
在最新版本中已弃用,建议使用PersistenceQuery
。
这里http://doc.akka.io/docs/akka/current/scala/persistence.html写成:
PersistentView: A view is a persistent, stateful actor that receives journaled messages that have been written by another persistent actor. A view itself does not journal new messages, instead, it updates internal state only from a persistent actor's replicated message stream.
PersistentView 的典型用例是什么?
它与 Akka Streams / RX 有何不同?
跟我长得很像
如果您基于 CQRS 设计应用程序,您可能会发现它很有用。 CQRS 非常适合事件源 系统,如博客 post.
中所示虽然您可能会使用 PersistentActor
actor 来更新应用程序的状态 - 这是命令端/模型,但当您想要显示数据时,PersistentView
actor 会派上用场,依此类推查询端。
一个例子是存储有关银行账户的数据。在传统模型中,您可能会在某个存储库下进行所有 CRUD 操作。此模型中的一个真正基本的转换是对 CUD 位使用 PersistentActor
,对 R 位使用 PersistentView
。好处是您将更新状态的命令部分与查询端分离。
至于最后一个问题,akka-persistence
和akka-streams
的目的不同。事实上 akka-persistence-query-experimental
实际上是使用 akka-streams
构建的,以提供不同的来源。一个例子实际上是here。请注意,PersistentView
在最新版本中已弃用,建议使用PersistenceQuery
。