Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the point of the Akka Microkernel using Java and Maven?

Tags:

java

akka

I developed an Akka-based server and liked the Microkernel idea. However, when I look at the implementation details using Java and Maven I'm trading in a simple Java main startup class for a framework specific solution that promises I don't need to write start up scripts and at the end I find it needs:

  • Akka installed (I could otherwise work without Akka installed only using the libraries)
  • I need two additional Maven related changes and an additional assembly artifact
  • I also need a "start" script so what's the point?

Maybe I am missing something? but I don't see any simpler setup or advantage compared to a plain old Java main solution.

UPDATE: thinking a bit more after getting the answer. There is possibly still a good case for writing your main class in terms of a Microkernel so that it could be started via the Akka console in the future e.g.

public class MapReduceServer implements Bootable {
    //---------------------------------------------------------------
    // public
    //---------------------------------------------------------------
    /**
     * Default constructor simply initializes the system.
     */
    public MapReduceServer() {
        system = ActorSystem.create("MapReduceApp", ConfigFactory.
                load().getConfig("MapReduceApp"));
    }

    //---------------------------------------------------------------
    /**
     * {@inheritDoc}
     */
    @Override
    public void startup() {
        // create the list of reduce Actors
        ActorRef reduceActor = system.actorOf(Props.create(ReduceActor.class)
                .withRouter(new FromConfig()), "reduceActor");

        // create the list of map Actors
        ActorRef mapActor = system.actorOf(Props.create(MapActor.class, reduceActor).
                withRouter(new FromConfig()), "mapActor");

        // create the overall Master Actor that acts as the remote actor for clients
        @SuppressWarnings("unused")
        ActorRef masterActor = system.actorOf(
                Props.create(MapReduceMasterActor.class, mapActor), "masterActor");
    }

    //---------------------------------------------------------------
    /**
     * {@inheritDoc}
     */
    @Override
    public void shutdown() {
        system.shutdown();
    }

    //---------------------------------------------------------------
    /**
     * Main method
     *
     * @param args
     */
    public static void main(String[] args) {
        MapReduceServer mapReduceServer = null;

        LOGGER.info("starting ...");
        mapReduceServer = new MapReduceServer();
        mapReduceServer.startup();
        LOGGER.info("done");
    }
like image 342
SkyWalker Avatar asked Jun 27 '13 12:06

SkyWalker


1 Answers

The Microkernel can be convenient as a packaging mechanism when using sbt, but for Maven users I agree that it doesn't add any value. I think you should use a main class and package your application the maven way.

like image 170
Patrik Nordwall Avatar answered Sep 27 '22 22:09

Patrik Nordwall