【问题标题】:Akka cluster sharding doesn't workAkka 集群分片不起作用
【发布时间】:2016-07-08 19:57:07
【问题描述】:

我在 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 正在由 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)
  }

【问题讨论】:

    标签: scala akka akka-cluster akka-persistence


    【解决方案1】:

    忘记添加种子节点

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 2020-12-09
      • 1970-01-01
      相关资源
      最近更新 更多