我需要与多个远程演员系统进行通信 [英] I need to communicate with multiple remote actor systems
问题描述
林用akka.Net开发一个插件架构即包含一个或多个插件每个DLL加载到自己的的AppDomain玩
和新的演员系统初始化准备从主机收到消息。
Im playing with using akka.Net to develop a plugin architecture whereby each dll that contains one or more plugins is loaded into its own AppDomain
and a new actor system is initialized ready to recieve messages from the "Host".
我成为脱胶试图让这个与多个插件工作。
I become unstuck trying to get this to work with multiple plugins.
所以主机的配置如下:
akka {
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
}
remote {
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 50003
hostname = localhost
}
}
}
和插件的配置如下:
akka {
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
}
remote {
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 50004
hostname = localhost
}
}
(有许多这样的)
我的问题是我如何得到主机的消息给所有的插件?
My question is how do i get messages from the Host to all of the plugins?
推荐答案
最好的建议是使用Akka.Cluster。这里有一个证据充分的例子: https://github.com/petabridge/akkadotnet-code -samples /树/主/ Cluster.WebCrawler
The best recommendation is to use Akka.Cluster. Here's a well-documented example: https://github.com/petabridge/akkadotnet-code-samples/tree/master/Cluster.WebCrawler
让每个插件配置使用动态端口( akka.remote.helios。 tcp.port = 0
),然后定义一个集群路由器会谈演员系统履行特定角色。
Have each plugin config use a dynamic port (akka.remote.helios.tcp.port = 0
) and then define a clustered router that talks to actor systems fulfilling specific roles.
/api/broadcaster {
router = broadcast-group
routees.paths = ["user/api"]
cluster {
enabled = on
max-nr-of-instances-per-node = 1
allow-local-routees = on
use-role = crawler
}
}
这路由器,部署在路径用户/ API /广播
上的一些节点进行通信(通过广播
路由策略)与作用在集群中部署在路径用户/ API
的任何节点上的任何演员履带
无需查找IP地址,端口,或任何废话。
This router, deployed at the path user/api/broadcaster
on some node can communicate (via the Broadcast
routing strategy) with any actor deployed at path user/api
on any node in the cluster with role crawler
without needing to look up IP addresses, ports, or any of that crap.
您配置一个节点的集群通过在Akka.NET的配置以下部分的信息:
You configure a node's clustering information via the following section in Akka.NET's config:
cluster {
#manually populate other seed nodes here, i.e. "akka.tcp://lighthouse@127.0.0.1:4053"
seed-nodes = ["akka.tcp://webcrawler@127.0.0.1:4053"]
roles = [crawler]
}
种子节点 - 已成为一个众所周知的,静态定义的端口和IP地址。阅读的文章为什么这是很重要的一个解释
Seed nodes - has to be a well-known, statically-defined port and IP address. Read the article for an explanation on why this is important.
角色 - 定义了这个特殊的节点的能力是逗号分隔字符串。它们更像是标签。您可以使用它们集群路由器内部(如我之前展示)阐明你想与之通信的类型的节点。
Roles - comma-delimited strings that define what this particular nodes' capabilities are. They're more like tags. You can use them inside clustered routers (like the one I showed earlier) to articulate which types of nodes you want to communicate with.
这篇关于我需要与多个远程演员系统进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!