welcome to section 5 working with akka
cluster in the previous section we
worked with akka persistence we
discussed akka persistence architecture
and implemented a persistent actor then
we implemented persistence FSM and
finally discussed persistence query in
this section we will work with other
features in occur such as a quorum oat
and akka cluster first we will introduce
occur remoting and implement a remote
actor then we will introduce a cluster
and implement some concepts on it such
as load balancer cluster sharding and
cluster singleton let's starts with akka
remoting in this first video in this
video we will take a look at
introduction to a career Moton preparing
your actor system for occur remoting
starting a remote actor let's get
started in all the previous sections
until now we have worked on examples
that have one actor system running on a
local machine but in real life your
application will pertain to parts and
every part may run on a different node
everything in akka is designed to work
in a distributed setting and the a
khadeem has done a great job protecting
the application from all the complexity
that revolves around the remoting system
now let's define a kareem outing akka
remoting is a communication module to
connect actor systems in a peer-to-peer
fashion and it is the foundation for a
clustering in a production setting it is
recommended to rely on akka cluster
directly instead of remoting however
let's see how it works before we jumped
the cluster let's start playing with
akka remoting akka remoting like Acker
persistence is a separate dependency so
we should be adding this dependency in
our application now to enable ack
remoting we should update our
application confiar we should at least
add these four things in our
configuration first we should change the
provider from a corrector local actor
ref provider to a Kodomo top remote
actor ref provider
second we add a tcp on the enabled
transports list third we define a
hostname let's say it's our localhost
and finally we define a port let's say
it is two five five to each actor system
needs to have either a unique port if
shared on the same host or they can use
the same port if started on multiple
nodes in the cluster now our application
is ready great
here is a worker actor that handles work
messages and when it receives a work
message it just prints that message now
let's create our actor system using our
configuration in the member service
object we will load our configuration
and then create our system then let's
create an instance of the worker actor
this code is similar to the code from
the previous sections but the only
difference is that this actor system is
a remote actor system now let's run this
actor system
great actor system is running and here
we have the path for our worker actor we
have two types of remote interactions
lookup and creations lookup is used to
look up an actor on a remote node with
actor selection creation is used to
create an actor on a remote node with
actor of let's start with the lookup
example first we'll add the
configuration for member service lookup
actor system it is similar to our
previous configuration but we will
change the port now in the member
service lookup object we need to start
our actor system first we need to read
our configuration
then we need to send the message to the
worker actor in another actor system we
will use the actor selection method the
pattern of remote actors path like this
it's like a path for normal actor but we
provide the remote system host and port
so let's add the actor selection for the
worker then let's send a message for the
selection actor now let's run the member
services look up actor system now let's
check the first terminal yeah the worker
actor receives our message excellent now
let's try another remote interaction
first let's add our configuration in
this example we will add some extra
configuration to describe the deployment
for the remote worker service here is
the creation of member service creation
it is our new actor system now we will
create a remote worker service actor
using actor off like any normal creation
and then send a message to it now let's
run the third actor system yeah there is
our message let's check our terminal for
the first actor yeah our worker actor
received our message awesome well done
you can check full documentation for
Acker remoting from here
you