Search in sources :

Example 6 with EventSink

use of org.nustaq.kontraktor.reactivestreams.EventSink in project kontraktor by RuedigerMoeller.

the class TCPNIOKStreamsTest method testServer.

@Test
@Ignore
public void testServer() throws InterruptedException {
    AtomicLong counter = new AtomicLong(0);
    EventSink<String> stringStream = new EventSink<>();
    stringStream.serve(getRemotePublisher(), actor -> {
        System.out.println("disconnect of " + actor);
    });
    int prev = 0;
    long l = System.currentTimeMillis();
    while (true) {
        long cn = counter.get();
        if (stringStream.offer("" + cn)) {
            counter.incrementAndGet();
        }
        if (System.currentTimeMillis() - l > 1000) {
            System.out.println("sent:" + cn);
            System.out.println("    :" + (cn - prev));
            prev = (int) cn;
            l = System.currentTimeMillis();
        }
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) EventSink(org.nustaq.kontraktor.reactivestreams.EventSink) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 EventSink (org.nustaq.kontraktor.reactivestreams.EventSink)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 TCPPublisher (org.nustaq.kontraktor.remoting.tcp.TCPPublisher)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 KxReactiveStreams (org.nustaq.kontraktor.reactivestreams.KxReactiveStreams)3 ActorPublisher (org.nustaq.kontraktor.remoting.base.ActorPublisher)3 ConnectableActor (org.nustaq.kontraktor.remoting.base.ConnectableActor)3 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)3 IntStream (java.util.stream.IntStream)2 Assert (junit.framework.Assert)2 Ignore (org.junit.Ignore)2 Actors (org.nustaq.kontraktor.Actors)2 DispatcherThread (org.nustaq.kontraktor.impl.DispatcherThread)2 ActorServer (org.nustaq.kontraktor.remoting.base.ActorServer)2 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)2 TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)2 TCPServerConnector (org.nustaq.kontraktor.remoting.tcp.TCPServerConnector)2 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)2 Log (org.nustaq.kontraktor.util.Log)2