1
votes

I am trying to create Akka Actors on a remote host. Following the official documentation, I create a remote Actor System parsing the application.config file and then I create a new actor. This is my code:

public static void main(String[] args) {

    Config config = ConfigFactory.parseFile(new File("application.conf"));
    ActorSystem system = ActorSystem.create("system",config);
    ActorRef actor = system.actorOf(Props.create(SampleActor.class), "sampleActor");
    System.out.println(actor.path());
    actor.tell("Hello", ActorRef.noSender());
}

And this is how I set up the application.conf file:

akka { actor { provider = remote } remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = "shielded-atoll-29637.herokuapp.com" port = 2552 } } }

Further details:

  • Akka protocol is provided by default by Akka
  • shielded-atoll-29637.herokuapp.com is the default domain of my server hosted on heroku.

The point is: should I take another server or heroku is sufficient? In case Heroku is okay, am I supposed to write a server application that is listening on the port 2552 for incoming actor-creating requests? Because the documentation does not mention anything at all.

Thanks in advance, Giacomo

3

3 Answers

0
votes

Considering that I need an IP or domain name and the port on the firewall should be open I think Akka is not the best solution to create a distribute system on mobile devices. It is good, for example, in a company which has servers inside their network with static IP and configurable firewalls.

0
votes

While you can start actors on a remote ActorSystem, you must have already deployed that ActorSystem with all the code you want to be able to trigger. This is usually used by different nodes that are all part of the same cluster. Your situation seems a little different.

I don't think deploying Akka on Heroku in this way will work: if I remember correctly Heroku is highly HTTP-centric, so I doubt it'll correctly make sure your Akka-based application is started when a connection is made to port 2552.

It might make more sense to deploy your server code on Heroku and trigger is though HTTP. That way you're playing more nicely with how Heroku is designed to work, and the implementation can still be either Akka-based (with akka-http) or something completely different.

Do consider that Heroku will want you to offload long-running processes to worker nodes, so it really depends on what you're trying to do whether that's a good solution.

0
votes

You can use Heroku Private Spaces to configure and deploy a Dyno with the actors you want to use remotely. Since you can't know the IP-address of another Dyno you should use Private Spaces DNS Service Discovery to work with hostnames. The server-Dyno should bind using that hostname and the client Dyno should use that hostname to make the connection.