Simple example of RSocket server & client implementation with conjunction of WebFlux.
Follow steps in order:
- Build
example-webflux-rsocket-lib
module and then, - Run
example-webflux-rsocket-server
module, - Run
example-webflux-rsocket-client
module.
Once server
and client
are up and running you should see similar logs to this below for:
client
2022-11-12 21:19:39.824 INFO 6692 --- [ main] com.pl.df.client.ClientController : Sending [The 1st message 1] message to server.<br>
2022-11-12 21:19:39.879 INFO 6692 --- [actor-tcp-nio-2] com.pl.df.client.ClientController : Received [ServerMessage and The 1st message 1!] message from server.
server
2022-11-12 21:19:39.861 INFO 5192 --- [ctor-http-nio-3] com.pl.df.server.ServerController : Received [The 1st message 1] message from client.
2022-11-12 21:19:39.861 INFO 5192 --- [ctor-http-nio-3] com.pl.df.server.ServerController : Producing [ServerMessage and The 1st message 1!] massage back to client.
Following APIs are exposed:
When requesting http://localhost:8082/client/send/message/john
resource expect results similar as presented below:
client
2022-11-12 21:38:08.345 INFO 8048 --- [ctor-http-nio-3] com.pl.df.client.ClientController : Sending [john 2] message to server.
2022-11-12 21:38:08.357 INFO 8048 --- [actor-tcp-nio-2] com.pl.df.client.ClientController : Received [ServerMessage and john 2!] message from server.
server
2022-11-12 21:38:08.355 INFO 5192 --- [ctor-http-nio-4] com.pl.df.server.ServerController : Received [john 2] message from client.
2022-11-12 21:38:08.356 INFO 5192 --- [ctor-http-nio-4] com.pl.df.server.ServerController : Producing [ServerMessage and john 2!] massage back to client.
When requesting http://localhost:8082/client/send/object-message/john
resource expect results similar as presented below:
client
2022-11-12 21:39:33.113 INFO 8048 --- [ctor-http-nio-3] com.pl.df.client.ClientController : Sending [ObjectMessage(number=3, clientMessage=john, serverMessage=null)] object-message to server.
2022-11-12 21:39:33.191 INFO 8048 --- [actor-tcp-nio-2] com.pl.df.client.ClientController : Received [ObjectMessage(number=3, clientMessage=john, serverMessage=john 3)] object-message from server.
server
2022-11-12 21:39:33.180 INFO 5192 --- [ctor-http-nio-4] com.pl.df.server.ServerController : Received [ObjectMessage(number=3, clientMessage=john, serverMessage=null)] object-message from client.
2022-11-12 21:39:33.180 INFO 5192 --- [ctor-http-nio-4] com.pl.df.server.ServerController : Producing [ObjectMessage(number=3, clientMessage=john, serverMessage=john 3)] object-message back to client.
JDK 17 or higher.