MSF4J
Github:https://github.com/wso2/msf4j
MSF4J 是 Java 輕量級高效能的 WSO2 微服務架構。
範例程式碼:
//Application.javapublic class Application { public static void main(String[] args) { new MicroservicesRunner() .deploy(new HelloService()) .start(); }}//HelloService.javapackage org.example.service; import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.PathParam;@Path("/hello")public class HelloService { @GET @Path("/{name}") public String hello(@PathParam("name") String name) { return "Hello " + name; }}
效能比較:
記憶體佔用比較:
Microserver
Github:https://github.com/aol/micro-server
Microserver 是一個零配置、基於標準的身經百戰的庫,用來運行 Java REST 微服務,通過 Java 標準 main 類執行。從 2014 年開始就一直在 AOL 生產環境中使用。
架構結構:
main 類:
public class AppRunnerTest { public static void main(String[] args) throws InterruptedException { new MicroserverApp(() -> "test-app").run(); }}
服務類:
@Rest @Path("/status")public class StatusResource { @GET @Produces("text/plain") @Path("/ping") public String ping() { return "ok"; }}