Coder Social home page Coder Social logo

hello-akka-cluster's Introduction

#Learning AKKA Cluster

Configuration

  • ShardingMainNode2 app demonstrate how to override a property in application.conf and pass that overriden property value during the creation of the actor system.
  • Without overriding the default value of property akka.remote.artery.canonical.port you will get the error below if ShardingMain app is already running. You will also get the same error when you run ShardingMain app while ShardingMainNode2 is already running.
xception in thread "main" akka.remote.RemoteTransportException: Failed to bind TCP to [127.0.0.1:2551] due to: Bind failed because of java.net.BindException: Address already in use[ERROR] [07/12/2019 07:51:36.723] [cluster-sharding-learning-akka.actor.default-dispatcher-4] [akka://[email protected]:2551/system/IO-TCP/selectors/$a/0] Bind failed for TCP channel on endpoint [/127.0.0.1:2551]

Clustering

  • If you start the app ShardingMainNode2 without the app ShardingMain 1st running you will get the error below this is because as per configuration in application.conf The leader node will be running on port 2551 (which is the port use by ShardingMain app)
cluster {
    seed-nodes = [
      "akka://[email protected]:2551"]}
 Cluster Node [akka://[email protected]:2552] - Couldn't join seed nodes after [2] attempts, will try again. seed-nodes=[akka://[email protected]:2551]
  • If you have the two app ShardingMain and ShardingMainNode2 create an actor system with different name you will see this warning in the log, because it expects that nodes in the same AKKA cluster have the same ActorSystem anme
Cluster Node [akka://[email protected]:2552] - Trying to join member with wrong ActorSystem name, but was ignored, expected [cluster-sharding-learning-node2] but was [cluster-sharding-learning]
  • Successful clustering to a seed node will be mark by a log entry below
Cluster Node [akka://[email protected]:2552] - Welcome from [akka://[email protected]:2551]

Cluster Singleton

  • SingletonRunnerAppNode1 and SingletonRunnerAppNode2 demonstrate two applications joining in once cluster
  • SingletonRunnerAppNode1 must be run first as it is the seed node as specified in application-singleton.conf
  • Checked the log of SingletonRunnerAppNode1 and notice that new Hello("World from node2") message being sent from node2 is getting log showing that the Endpoint actor ref was created as singleton within the cluster
  • When node 2 is sending a message to cluster-singleton-proxy actor ref it expects that serializaiton for Endpoint.Hello is defined

Serialization

  • application-singleton.conf defines serialization required for Endpoint.Hello
    • Key configuration required for serialization
      • akka.extensions
      • akka.actor.enable-additional-serialization-bindgings
      • akka.actor.allow-java-serialization
      • akka.actor.serializers
      • akka.actor.serialization-bindings
      • akka.actor.kryo

hello-akka-cluster's People

Contributors

novemberswimmer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.