I am at a loss as to what I am doing wrong here. Any help would be very 
much appreciated. 

I have three "nodes", all in separate executables. 

I have the "Lighthouse", which is the concept illustrated here: 

Here is the code for it:

*pom.xml*
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xmlns="http://maven.apache.org/POM/4.0.0";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>fakename.lighthouse</groupId>
    <artifactId>lighthouse</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-slf4j_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
    </dependencies>
</project>

*application.conf*
akka {
  loglevel = "INFO"
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 5309
    }
  }

  version = "2.3.11"

  cluster {
    seed-nodes = ["akka.tcp://[email protected]:5309"]
    auto-down-unreachable-after = 10s
    roles = ["lighthouse"]
  }
}

*Main.java*
import akka.actor.ActorSystem;
import com.typesafe.config.ConfigFactory;

public class Main {
    private static ActorSystem clusterSystem;

    public static void main(String... args) {
        clusterSystem = ActorSystem.create("ClusterSystem", ConfigFactory.
load("application"));
    }
}



Next, I have my akka-http node.

*pox.xml*
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>fakename.api</groupId>
    <artifactId>api</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-slf4j_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-http-java-experimental_2.11</artifactId>
            <version>1.0-RC2</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-stream-experimental_2.11</artifactId>
            <version>1.0-RC2</version>
        </dependency>
    </dependencies>
</project>

*application.conf*
akka {
  loglevel = "INFO"
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
    deployment {
      /"*"/productsRouter = {
        router = adaptive-group
        metrics-selector = mix
        nr-of-instances = 2
        routees.paths = ["/user/productsActor"]
        cluster {
          enabled = on
          use-role = products
          allow-local-routees = on
        }
      }
    }
  }

  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 97
    }
  }

  version = "2.3.11"

  cluster {
    seed-nodes = ["akka.tcp://[email protected]:5309"]
    auto-down-unreachable-after = 10s
    roles = ["api"]
  }
}



*Endpoint.java*
getProducts


And last, but not least, I have the third node which houses the actual 
instances of the actors.

*pom.xml*
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>fakename.products</groupId>
    <artifactId>products</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-cluster_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-slf4j_2.11</artifactId>
            <version>2.3.11</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-http-java-experimental_2.11</artifactId>
            <version>1.0-RC2</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-stream-experimental_2.11</artifactId>
            <version>1.0-RC2</version>
        </dependency>
    </dependencies>
</project>

*application.conf*
akka {
  loglevel = "INFO"
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 96
    }
  }

  version = "2.3.11"

  cluster {
    seed-nodes = ["akka.tcp://[email protected]:5309"]
    auto-down-unreachable-after = 10s
    roles = ["products"]
  }
}

*Main.java*
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.cluster.Cluster;
import com.typesafe.config.ConfigFactory;
import scala.concurrent.Future;

import static akka.dispatch.Futures.future;
import static akka.pattern.Patterns.pipe;

public class Main {
    private static ActorSystem clusterSystem;

    public static void main(String... args) throws InterruptedException {
        clusterSystem = ActorSystem.create("ClusterSystem", 
ConfigFactory.load("application"));

        Cluster.get(clusterSystem).registerOnMemberUp(() -> 
clusterSystem.actorOf(Props.create(ProductsActor.class), "productsActor"));
    }
}

class ProductsActor extends UntypedActor {

    @Override
    public void onReceive(Object message) throws Exception {

        Future<String> f = future(() -> "Hello!!!!", 
getContext().dispatcher());

        pipe(f, getContext().dispatcher()).to(getSender());
    }
}


So if I run all three nodes, they all start up and join the cluster. I get 
welcome messages, gossip, heartbeats, everything. But when I hit the 
akka-http endpoint at http://localhost:4200/v1/products I am greeted with 
the message:
[INFO] [07/07/2015 16:57:48.127] 
[ClusterSystem-akka.actor.default-dispatcher-16] 
[akka://ClusterSystem/user/testActor] Message [java.lang.String] from 
Actor[akka://ClusterSystem/user/$b#1210641087] to 
Actor[akka://ClusterSystem/user/testActor] was not delivered. [1] dead 
letters encountered. This logging can be turned off or adjusted with 
configuration settings 'akka.log-dead-letters' and 
'akka.log-dead-letters-during-shutdown'.

If I remove the third node and just move the products actor into the same 
executable as the akka-http node, everything works fine.

What am I missing? I am going to guess it is a configuration issue, but I 
am still so new to akka. Any help would be appreciated.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to