码迷,mamicode.com
首页 > 其他好文 > 详细

akka 的集群访问方式

时间:2019-06-11 19:22:09      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:via   ted   can   sha   set   region   art   red   before   

akka  中采用startProxy分区代理 访问 ,跟使用shardRegion 来访问的区别

 

这两种访问方式是不是重了呢。

 而另外这是一个单例代理

protected fun startUniverseProxy(universeRole: UniverseRole) {
val proxySettings = ClusterSingletonProxySettings.create(actorSystem).withRole(universeRole.clusterRole.name)
val actorRef: ActorRef = actorSystem.actorOf(ClusterSingletonProxy.props(universeRole.proxyPath, proxySettings))
universeProxies[universeRole] = actorRef
}

worldActor 中 又 创建了一个访问对象
/**
* Retrieve the actor reference of the [[ShardRegion]] actor responsible for the named entity type.
* The entity type must be registered with the [[#start]] or [[#startProxy]] method before it
* can be used here. Messages to the entity is always sent via the `ShardRegion`.
*/
就是只要  
protected fun startUniverseCwarShardProxy() {
ClusterSharding.get(actorSystem).startProxy(
GameWorldShard.universe_cwar.name, Optional.of(ClusterRole.universe_cwar.name),
UCWorldMessageExtractor()
)
.let { logger.info("UniverseCwar shard proxy $it started.") }
}
开始的方式, 就能以以下的方式获取到
ClusterSharding.get(context.system()).let {
ucWorldShardProxy = it.shardRegion(GameWorldShard.universe_cwar.name)
}

akka 的集群访问方式

标签:via   ted   can   sha   set   region   art   red   before   

原文地址:https://www.cnblogs.com/vana/p/11005274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!