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:
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");
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With