Akka群集分片不起作用

时间:2016-07-08 19:57:08

标签: scala akka akka-cluster akka-persistence

我在Scala 2.11.8上使用akka 2.4.7。

事件来自extractShardId和extractEntityId,但它们没有被传播到actor的receive方法。什么可能是什么想法?

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由Persistence Query

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

1 个答案:

答案 0 :(得分:0)

忘记添加种子节点

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