Simpler concurrency | |
Partition your application into message passing single threaded services. Scale out and distribute as needed at deployment time. |
Write once, wire everywhere | |
TCP, WebSockets, Http-LongPoll or in-process: Message transport and encoding is configurable. No need
to change your application code. |
JavaScript Interop | |
Kontraktor brings back simplicity and lightweightness to server side Java. |
High performance | |
Expect kontraktor to outperform competition by an order of magnitude for many use cases. |
public class HelloActor extends Actor<HelloActor> { public IPromise greet( String name ) { return new Promise("Hello "+name); } public static void main(String a[]) { HelloActor myService = AsActor(HelloActor.class); System.out.println( myService.greet("Kontraktor").await() ); } }
HelloActor myService = AsActor(HelloActor.class); new WebSocketPublisher() .facade(myService) .hostName("localhost") .urlPath("/hello") .port(8080) .serType(SerializerType.FSTSer) .publish();
HelloActor myService = (HelloActor) new WebSocketConnectable(HelloActor.class ,"http://localhost:8080/hello") .serType(SerializerType.FSTSer) .connect(null) .await(); System.out.println( myService.greet("Kontraktor").await() );
jsk.connect("ws://localhost:8080/ws","WS") .then( function( app, error ) { app.ask("greet", "kontraktor") .then( function(res,err) { console.log("greeting:"+res); } };
// create server actor MyHttpApp app = AsActor(MyHttpApp.class); Http4K.Build("localhost", 8080) .fileRoot( "/", root) .httpAPI( "/api", app) .serType(SerializerType.JsonNoRef) .setSessionTimeout(30_000) .build() .websocket("ws", app ) .serType(SerializerType.JsonNoRef) .build() .resourcePath( "/dyn" ) .rootComponent("app") .resourcePath( "./web", "./web/components", "./web/lib") .devMode(false) .build() .build();
Transport | Throughput tell/sec | Throughput ask/sec | supported # Clients | Use case |
---|---|---|---|---|
None (VM Local) | 5-7 million | 2-3 million | n/a (a lot) | simpler concurrency model, system scale down |
TCP Blocking | 2.2 million | 1 million | <500 (2 Threads per client) | System Interconnect |
TCP NIO | 1.8 million | 0.8 million | >10_000 | Service Provider, System interconnect |
WebSocket | 1.8 million | 1 million | >10_000 | System Interconnect, Serve GUI Clients, Service Provider |
Http-Long Poll | 400_000 | 250_000 | >10_000 | Serve GUI + Mobile Clients, Unstable networks |
Http-Long Poll JSON | 200_000 | 120_000 | >10_000 | Serve GUI + Mobile Clients, Unstable networks |
Kontraktor Core (Actors + TCP Remoting), requires Java 8, LGPL Licensed
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>kontraktor</artifactId>
<version>3.06</version>
</dependency>
Kontraktor Http (WebSockets, Http LongPoll, Single Page App + JavaScript interop support), requires Java 8, LGPL Licensed
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>kontraktor-http</artifactId>
<version>3.06</version>
</dependency>
Kontraktor-Reactive Streams (Implements Reactive Streams Spec 1.0), LGPL Licensed
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>kontraktor-reactive-streams</artifactId>
<version>3.06</version>
</dependency>
Kontraktor-Bare (Minimalistic standalone Http-LongPoll client [legacy apps, Android] ), requires Java 7, Apache 2.0 Licensed
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>kontraktor-bare</artifactId>
<version>3.06</version>
</dependency>
js4k.js for node.js Apache 2.0 Licensed
npm install "js4k"requires websocket, filereader + some entry code (see example)