我在 Scala 2.11.8 上使用 akka 2.4.7。
事件即将到达 extractShardId 和 extractEntityId 但它们没有被传播到参与者的接收方法。有什么想法吗?
https://bitbucket.org/kuzelac/apt-billing/overview分支价格分片
已经定义了一个集群分片:
val dailyPriceAggregateActor: ActorRef = ClusterSharding(context.system).start(
typeName = "DailyPriceAggregateActor",
entityProps = DailyPriceAggregateActor(),
settings = ClusterShardingSettings(context.system),
extractEntityId = DailyPriceAggregateActor.extractEntityId,
extractShardId = DailyPriceAggregateActor.extractShardId)
演员对象是
object DailyPriceAggregateActor {
def apply() = Props(classOf[DailyPriceAggregateActor])
val extractEntityId: ShardRegion.ExtractEntityId = {
case e@DailyPriceSaved(userId, unitId, _, _, _) => (s"$userId$unitId", e)
case e@LookupPriceForDay(userId, unitId, _) => (s"$userId$unitId", e)
}
val extractShardId: ShardRegion.ExtractShardId = {
case _ => "one"
}
}
我已将 conf 设置为
akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
演员正在被持久性查询播种
def startSync(actor: ActorRef) = {
val queries = PersistenceQuery(context.system).readJournalFor[ScalaDslMongoReadJournal](MongoReadJournal.Identifier)
val src: Source[EventEnvelope, NotUsed] =
queries.eventsByPersistenceId(PriceAggregateActor.persistenceId, 0L, Long.MaxValue)
src.runForeach(actor ! _.event)
}