Akka 集群分片不起作用

Akka cluster sharding doesn't work

我在 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"

Actor 正在通过持久性查询播种

  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)
  }

忘记添加种子节点

seed-nodes = [
  "akka.tcp://{your-actor-system-name}@127.0.0.1:8999"
]