[英]what's the point of the Akka Microkernel using Java and Maven?
我開發了一個基於Akka的服務器,並喜歡Microkernel的想法。 但是,當我使用Java和Maven查看實現細節時,我在一個簡單的Java主要啟動類中交換一個框架特定的解決方案,承諾我不需要編寫啟動腳本,最后我發現它需要:
也許我錯過了什么? 但與普通的舊Java主解決方案相比,我沒有看到任何更簡單的設置或優勢。
更新:在得到答案后再思考一下。 根據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");
}
使用sbt時,Microkernel可以方便地作為打包機制,但對於Maven用戶,我同意它不會增加任何價值。 我認為你應該使用主類並以maven方式打包你的應用程序。
至少微內核為您保存了關閉鈎子的定義(處理CTRL-C)。 在普通的主要方法中,這是您的關注點。 當然沒有什么特別的或花哨的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.