Maven support for rsocket rcp compiler


#1

has anyone created a pom to run the rcp compiler on the Protobuf compiler generated java files?


#2

If you look at proteus-spring-quickstart there is an example of using protobuf-maven-plugin along with the rsocket-rpc-protobuf plugin to compile rsocket-rpc service definitions: https://github.com/netifi/proteus-spring-quickstart/blob/master/service-idl/pom.xml


#3

Thanks.

How about from the page https://proteus-java.readthedocs.io/en/latest/

Working example

To see a working example of the code described here please view the SimpleServiceTest class.
This page does not exist, has it moved?


#4

Hi - that is old documentation - please checkout https://github.com/rsocket/rsocket-rpc-java/blob/master/docs/get-started.md

Thanks,
Robert


#5

Thanks, next question. The io.netifi.proteus packages are not in maven, I have only found the jar files in a git repo, are they intended for production and if so why are they not in maven central. Is there another set of packages I should be using in their place?

Ok found the answer, you have your own public repo, added to my settings.xml, now I have access to your repo.


#6

Referring to https://github.com/rsocket/rsocket-rpc-java/blob/master/docs/get-started.md
I created the DefaultSimpleService and then the server
public class ServerMain
{
private static final Logger logger = LoggerFactory.getLogger(ServerMain.class);

public static void main(String… args) throws Exception
{
logger.info(“Starting ServerMain”);
/*
RSocket RPC Server Configuration

  Each generated service has a client and server implementation generated for you. After you have
  implemented the generated interface you need to hand the implementation to the server.
 */
SimpleServiceServer serviceServer = new SimpleServiceServer(new DefaultSimpleService(), Optional.empty(), Optional.empty());

/*
  Once you have created an instance of the the server you need to configure RSocket.
  The following is a RSocket server configuration.
 */
CloseableChannel server = RSocketFactory
    .receive()
    .acceptor((setup, sendingSocket) -> Mono.just(
        new RequestHandlingRSocket(serviceServer)
    ))
    .transport(TcpServerTransport.create(8081))
    .start()
    .block(Duration.ofSeconds(10));

logger.info("server created");
// Keep the Service Running

// Thread.sleep(15_000);
// server.dispose();
// logger.info(“server shutdown”);
// server.onClose().block();
}
}

I started the server and then the client and it fails to connect to the server
[main] INFO io.rsocket.rpc.testing.protobuf.ClientMain - Starting ClientMain
Exception in thread “main” reactor.core.Exceptions$ReactiveException: io.netty.channel.AbstractChannel$AnnotatedConnectException: syscall:getsockopt(…) failed: Connection refused: /127.0.0.1:8801
at reactor.core.Exceptions.propagate(Exceptions.java:326)
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:131)
at reactor.core.publisher.Mono.block(Mono.java:1517)
at io.rsocket.rpc.testing.protobuf.ClientMain.main(ClientMain.java:43)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:133)
… 2 more
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: syscall:getsockopt(…) failed: Connection refused: /127.0.0.1:8801
at io.netty.channel.unix.Socket.finishConnect(…)(Unknown Source)
Caused by: io.netty.channel.unix.Errors$NativeConnectException: syscall:getsockopt(…) failed: Connection refused
… 1 more

any ideas what I missed?


#7

Hi,

Proteus-RPC became RSocket RPC and those packages are in MavenCentral:
https://search.maven.org/search?q=rsocket-rpc

The proteus client for the proteus broker is in JCenter.

Your exception says Connection refused: /127.0.0.1:8801 not 8081. Are you connecting to the wrong port?

Thanks,
Robert


#8

fixed the port mismatch both 8081. The real issue is that the server process has completed in less than one second, leaving nothing for the client to connect to.


#9

Hi,

The server threads are daemons so you need to block somewhere so you don’t exit. You can do something like this:

public static void main(String... args) throws Exception {
    SimpleServiceServer serviceServer = new SimpleServiceServer(new DefaultSimpleService(), Optional.empty(), Optional.empty());
    CloseableChannel closeableChannel =
        RSocketFactory.receive()
            .acceptor(
                (setup, sendingSocket) -> Mono.just(new RequestHandlingRSocket(serviceServer)))
            .transport(TcpServerTransport.create(8081))
            .start()
            .block();
    
    // Block so we don't exit
    closeableChannel.onClose().block();
}

I created an example project from the rsocket-rpc-java readme:

Thanks,
Robert


#10

Thanks for your help Robert. Lowell