I need to communicate with several remote acting systems

Im playing using akka.Net to develop a plugin architecture in which each dll containing one or more plugins is loaded into its own AppDomain and the new actor system is initialized to receive messages from "Host".

I stop trying to get this to work with multiple plugins.

So, the host configuration looks like this:

 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 } } } 

And the plugin configuration looks like this:

 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 } } 

(a lot of them)

My question is how to get messages from the host to all plugins?

+6
source share
1 answer

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

Edit - removed the offer to use the dynamic port. It is much better to use static ones, so node reloading can be done correctly.

Ask each plugin configuration to use a plugin- akka.remote.helios.tcp.port = 1231 port ( akka.remote.helios.tcp.port = 1231 ), and then define a cluster router that interacts with actor systems that perform 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 } } 

This router, deployed on the user/api/broadcaster path on some node, can communicate (via the Broadcast routing strategy) with any player deployed on the user/api path on any node in the crawler role without having to look for IP addresses, ports or any of them.

You configure node clustering information through the following section in the Akka.NET configuration:

 cluster { #manually populate other seed nodes here, ie "akka.tcp:// lighthouse@127.0.0.1 :4053" seed-nodes = ["akka.tcp:// webcrawler@127.0.0.1 :4053"] roles = [crawler] } 

Seed Nodes - Must be a well-known, statically defined port and IP address. Read the article to explain why this is important.

Roles are comma-delimited strings that determine what the capabilities of this particular node are. They are more like tags. You can use them in cluster routers (for example, the one I showed earlier) to formulate what types of nodes you want to communicate with.

+10
source

Source: https://habr.com/ru/post/983992/


All Articles