Search in sources :

Example 1 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class HelloActor method main.

public static void main(String[] a) {
    HelloActor myService = AsActor(HelloActor.class);
    // as websocket service fast serialialized
    new WebSocketPublisher().facade(myService).hostName("localhost").urlPath("/hello").port(8080).serType(SerializerType.FSTSer).publish();
    // as http long poll service, json encoding
    new HttpPublisher().facade(myService).hostName("localhost").urlPath("/hellohttp").port(8080).serType(SerializerType.JsonNoRefPretty).publish();
    // as tcp nio service, fast serialized
    new TCPNIOPublisher().facade(myService).port(6789).serType(SerializerType.FSTSer).publish().await();
}
Also used : WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)

Example 2 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class FSTJsonJSTest method main.

public static void main(String[] a) {
    HttpClientConnector.DumpProtocol = true;
    File root = new File("../fast-serialization/src/main/web/");
    Http4K.get().publishFileSystem("localhost", "/", 8080, root);
    JSActor jsa = Actors.AsActor(JSActor.class);
    new HttpPublisher(jsa, "localhost", "/jsactor/", 8080).serType(SerializerType.JsonNoRefPretty).publish().await();
    JSActor client = (JSActor) new HttpConnectable(JSActor.class, "http://localhost:8080/jsactor").serType(SerializerType.JsonNoRefPretty).connect().await();
    System.out.println(client.say("blabla").await());
}
Also used : HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) File(java.io.File)

Example 3 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class RemotingTest method testHttpMany.

@Test
public void testHttpMany() throws Exception {
    checkSequenceErrors = false;
    RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
    ActorServer publisher = new HttpPublisher(service, "localhost", "/lp", 8082).publish().await();
    RemotingTestService client = (RemotingTestService) new HttpConnectable(RemotingTestService.class, "http://localhost:8082/lp").connect().await(9999999);
    ExecutorService exec = Executors.newCachedThreadPool();
    CountDownLatch latch = new CountDownLatch(10);
    for (int i = 0; i < 10; i++) {
        exec.execute(() -> {
            try {
                runWithClient(client, latch);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
    latch.await();
    // wait for outstanding callbacks
    Thread.sleep(2000);
    publisher.close();
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) ActorServer(org.nustaq.kontraktor.remoting.base.ActorServer) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) ExecutorService(java.util.concurrent.ExecutorService) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class RemotingTest method runtHttp.

public void runtHttp(Coding coding) throws InterruptedException {
    checkSequenceErrors = true;
    RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
    ActorServer publisher = new HttpPublisher(service, "localhost", "/lp", 8082).coding(coding).publish().await();
    RemotingTestService client = (RemotingTestService) new HttpConnectable(RemotingTestService.class, "http://localhost:8082/lp").coding(coding).connect().await(9999999);
    CountDownLatch latch = new CountDownLatch(1);
    runWithClient(client, latch);
    latch.await();
    // wait for outstanding callbacks
    Thread.sleep(2000);
    publisher.close();
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) ActorServer(org.nustaq.kontraktor.remoting.base.ActorServer) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 5 with HttpPublisher

use of org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher in project kontraktor by RuedigerMoeller.

the class BldFourK method httpAPI.

public HttpPublisher httpAPI(String urlPath, Actor facade) {
    HttpPublisher hp = new HttpPublisher(this, facade, hostName, urlPath, port);
    items.add(hp);
    return hp;
}
Also used : HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)

Aggregations

HttpPublisher (org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)7 HttpConnectable (org.nustaq.kontraktor.remoting.http.HttpConnectable)3 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)3 File (java.io.File)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 ActorServer (org.nustaq.kontraktor.remoting.base.ActorServer)2 TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)2 ExecutorService (java.util.concurrent.ExecutorService)1 Http4K (org.nustaq.kontraktor.remoting.http.undertow.Http4K)1 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)1 TCPPublisher (org.nustaq.kontraktor.remoting.tcp.TCPPublisher)1 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)1