use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher 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();
}
use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.
the class ServiceActor method publishSelf.
protected void publishSelf() {
int defaultPort = getPort();
// service does not expose itself
if (defaultPort <= 0) {
Log.Warn(this, "Service " + getServiceDescription().getName() + " has no port and host configured. Unpublished.");
return;
}
Log.Info(this, "publishing self at " + defaultPort);
new TCPNIOPublisher(self(), defaultPort).publish(actor -> {
Log.Info(null, actor + " has disconnected");
});
}
use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.
the class ServiceRegistry method main.
public static void main(String[] args) {
options = parseCommandLine(args, new ServiceArgs());
if (!options.isSysoutlog()) {
Log.SetSynchronous();
// Log.Lg.setLogWrapper(new Log4j2LogWrapper(Log.Lg.getSeverity()));
}
ServiceRegistry serviceRegistry = Actors.AsActor(ServiceRegistry.class);
serviceRegistry.init();
new TCPNIOPublisher(serviceRegistry, options.getRegistryPort()).publish(actor -> {
Log.Info(null, actor + " has disconnected");
});
// log service activity
serviceRegistry.subscribe((pair, err) -> {
Log.Info(serviceRegistry.getClass(), pair.car() + " " + pair.cdr());
});
}
use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.
the class RxJava method remotingToJ8Streams.
@Test
public void remotingToJ8Streams() {
Observable<Integer> range = Observable.range(0, NUM_MSG / 4);
Publisher<Integer> pub = RxReactiveStreams.toPublisher(range);
KxReactiveStreams.get().asKxPublisher(pub).serve(new TCPNIOPublisher().port(3457));
RateMeasure rm = new RateMeasure("events");
Promise<Integer> finished = new Promise<>();
KxReactiveStreams.get().connect(Integer.class, new TCPConnectable().host("localhost").port(3457)).stream(stream -> {
long count = stream.map(i -> {
rm.count();
return i;
}).count();
finished.resolve((int) count);
});
Assert.assertTrue(finished.await(50000) == NUM_MSG / 4);
}
use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.
the class KxStreamServer method main.
public static void main(String[] args) {
// give fat queue
KxStreamServer server = Actors.AsActor(KxStreamServer.class, 256000);
server.init();
TCPNIOPublisher publisher = new TCPNIOPublisher(server, 7890);
publisher.publish(actor -> System.out.println("actor " + actor + " disconnected")).await();
System.out.println("server started at " + publisher);
}
Aggregations