use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable in project kontraktor by RuedigerMoeller.
the class Pong method main.
public static void main(String[] args) {
Pong pong = AsActor(Pong.class);
new TCPNIOPublisher().port(9080).serType(SerializerType.FSTSer).facade(pong).publish(x -> Log.Info(Pong.class, "disconnected " + x));
// we need to initiate ping pong. Assumes Ping is already running
Ping ping = (Ping) new TCPConnectable().host("localhost").port(9080).actorClass(Ping.class).serType(SerializerType.FSTSer).connect().await();
ping.receivePong(pong);
}
use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable in project kontraktor by RuedigerMoeller.
the class ServiceClient method run.
public void run() {
MyServiceInterface service = (MyServiceInterface) new TCPConnectable().actorClass(MyServiceInterface.class).host("localhost").port(6789).connect((connector, error) -> {
System.out.println("Disconnected from service .. exiting");
System.exit(0);
}).await();
service.addPerson(new Person("Hickory", "Heinz", 13, Sex.MALE));
service.addPerson(new Person("Blob", "Jim", 13, Sex.MALE));
service.addPerson(new Person("Gerstenbroich-Huckerbühl", "Mareike", 17, Sex.MALE));
service.listPersons(null, null, 13, (p, err) -> {
if (!Actor.isErrorOrComplete(err))
System.out.println("found: " + p);
else {
System.out.println("query finished");
System.exit(0);
}
});
}
use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable in project kontraktor by RuedigerMoeller.
the class PlainService method initPlainService.
public IPromise<PlainService> initPlainService(String name, String[] requiredServices, ServiceArgs options) {
if (requiredServices == null) {
this.requiredServices = new String[0];
} else {
this.requiredServices = requiredServices;
}
this.serviceName = name;
Promise p = new Promise();
self().init(new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort()), options, true).then((r, e) -> {
if (e == null) {
p.resolve(self());
} else {
p.reject(e);
}
});
return p;
}
use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable in project kontraktor by RuedigerMoeller.
the class RemotingTest method runnitTCP.
public void runnitTCP(CountDownLatch l, Coding coding) throws Exception {
RemotingTestService client = (RemotingTestService) new TCPConnectable().actorClass(RemotingTestService.class).host("localhost").port(8081).coding(coding).connect().await();
runWithClient(client, l);
// wait for outstanding callbacks
Thread.sleep(2000);
client.close();
}
use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable in project kontraktor by RuedigerMoeller.
the class RemotingTest method test.
@Test
public void test() {
RemotingTA serv = Actors.AsActor(RemotingTA.class);
// websocket
WebSocketPublisher pub = new WebSocketPublisher().facade(serv).hostName("0.0.0.0").urlPath("/websocket").port(7777).serType(SerializerType.FSTSer);
pub.publish().await();
WebSocketConnectable con = new WebSocketConnectable().actorClass(RemotingTA.class).url("ws://localhost:7777/websocket");
fromRemote(con);
// TCP NIO
new TCPNIOPublisher(serv, 7778).publish().await();
fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7778));
// TCP Sync
new TCPPublisher(serv, 7780).publish().await();
fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7780));
// Http-Longpoll
new HttpPublisher(serv, "0.0.0.0", "/httpapi", 7779).publish().await();
fromRemote(new HttpConnectable(RemotingTA.class, "http://localhost:7779/httpapi"));
}
Aggregations