[英]what's the point of the Akka Microkernel using Java and Maven?
I developed an Akka-based server and liked the Microkernel idea. 我开发了一个基于Akka的服务器,并喜欢Microkernel的想法。 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:
但是,当我使用Java和Maven查看实现细节时,我在一个简单的Java主要启动类中交换一个框架特定的解决方案,承诺我不需要编写启动脚本,最后我发现它需要:
Maybe I am missing something? 也许我错过了什么? but I don't see any simpler setup or advantage compared to a plain old Java main solution.
但与普通的旧Java主解决方案相比,我没有看到任何更简单的设置或优势。
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 eg
根据Microkernel编写主类可能仍然是一个很好的例子,以便将来可以通过Akka控制台启动,例如
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. 使用sbt时,Microkernel可以方便地作为打包机制,但对于Maven用户,我同意它不会增加任何价值。 I think you should use a main class and package your application the maven way.
我认为你应该使用主类并以maven方式打包你的应用程序。
At least the micro-kernel saved you the definitions of the shutdown hook (handling CTRL-C). 至少微内核为您保存了关闭钩子的定义(处理CTRL-C)。 In the plain main method this is your concern.
在普通的主要方法中,这是您的关注点。 Of course nothing special or fancy here.
当然没有什么特别的或花哨的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.