1

I have two different Java 8 projects that will live on different servers and which will both use Akka (specifically Akka Remoting) to talk to each other.

For instance, one app might send a Fizzbuzz message to the other app:

public class Fizzbuzz {
    private int foo;
    private String bar;

    // Getters, setters & ctor omitted for brevity
}

I've never used Akka Remoting before. I assume I need to create a 3rd project, a library/jar for holding the shared messages (such as Fizzbuzz and others) and then pull that library in to both projects as a dependency.

Is it that simple? Are there any serialization (or other Akka and/or networking) considerations that affect the design of these "shared" messages? Thanks in advance!

8
  • Why the DV? This question is on topic, is not a dupe, shows research and is an SSCCE. Oct 25, 2018 at 10:49
  • can you clarify how your question is different from this one?
    – Dan Simon
    Oct 25, 2018 at 17:39
  • Yes sir, its different for two reasons: (1) namely, because neither that other question nor its accepted answer mention serialization concerns (annotating the shared messages "beans" with something or having them implement Serializable, etc.) which is one of my main stated concerns above... Oct 25, 2018 at 19:01
  • 1
    Not sure what you mean by "supported project", but last release was Sept 27th: github.com/akka/akka/releases and last commit to master a few days ago: github.com/akka/akka/commits/master. So yes, it's evolving, and no, StackOverflow is not the official support channel :)
    – J0HN
    Oct 27, 2018 at 6:04
  • 1
    Depends on what kind of official support you want. Since akka is "invented" by Lightbend, I believe they have a paid support for it (they definitely have some subscription products for a more advanced stuff), so you might want to talk to Lightbend merketing to get that - but only if you really need official support :) Otherwise, if "community support" is enough - check out akka README.md: github.com/akka/akka#community - there are a few links to community "gravitation centers"
    – J0HN
    Oct 30, 2018 at 3:42

1 Answer 1

2
+100

Shared library is a way to go for sure, except there are indeed serialization concerns:

Akka-remoting docs:

When using remoting for actors you must ensure that the props and messages used for those actors are serializable. Failing to do so will cause the system to behave in an unintended way.

For more information please see Serialization.

Basically, you'll need to provide and configure the serialization for actor props and messages sent (including all the nested classes of course). If I'm not mistaking default settings will get you up and running without any configuration on your side, provided that everything you send over the wire is java-serializable.

However, default config uses default Java serialization, which is known to be quite inefficient - so you might want to switch to protobuf, kryo, or maybe even json. In that case, it would make sense to provide the serialization implementation and bindings as a shared library - either a dedicated one or a part of the "shared models" one that you mentioned in the question - depends if you want to reuse it elsewhere and mind/don't mind having serailization-related transitive dependencies popping all over the place.

Finally, if you allow some personal opinion, I would suggest trying protobuf first - it's binary format (read: efficient) and is widely supported (there are bindings for other languages). Kryo works well too (I have a few closed-source akka-cluster apps with kryo serialization in production), but has a few quirks with regards to collection/map handling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.