1、actorSelection,当涉及actor远程通信时,可以使用actorSelection。

context.actorSelection("akka.tcp://app@otherhost:1234/user/serviceB")

当需要对这个actor进行管理的话,可以通过发送

val identifyId = 1

context.actorSelection("akka.tcp://app@otherhost:1234/user/serviceB") ! Identify(identifyId)

Identify是一个所有actor全都认识且会自动回复的的case class,回复ActorIdentity

case ActorIdentity(`identifyId`, Some(ref)) =>
      context.watch(ref)
      context.become(active(ref))
case ActorIdentity(`identifyId`, None) => context.stop(self)  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-09-05
  • 2021-04-04
  • 2022-01-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-01
  • 2021-07-16
  • 2021-10-19
  • 2022-02-09
  • 2021-11-24
  • 2021-10-24
相关资源
相似解决方案