Creating remote actors on different machines
In this recipe, we are going to see how to create remote actors on different machines. We will need to start two separate Akka applications running on different ports (mimicking as if they are running on different machines) to demonstrate how to do it.
Getting ready
Just import the Hello-Akka
project; the prerequisites are the same as before. We will also need to have the Akka remoting dependency in our build.sbt
file.
How to do it...
- Create a new file named
application-1.conf
in theÂsrc/main/resources
directory with the following contents:
akka { Â actor { Â Â provider = "akka.remote.RemoteActorRefProvider" Â } Â remote { Â Â enabled-transports = ["akka.remote.netty.tcp"] Â Â Â Â netty.tcp { Â Â Â Â Â Â hostname = "127.0.0.1" Â Â Â Â Â Â port = 2552 Â Â Â Â } Â Â } Â }
- Create a second new file named
application-2.conf
in theÂsrc/main/resources
directory with the following contents...