Skip to content

reactive-rsocket-broker/ali-rsocket-graal-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alibaba Socket GraalVM native-image demo

This demo shows how to use Alibaba RSocket Broker with GraalVM native-image and Spring Boot 2.7.x.

If you want to use Spring Boot 3, please refer https://github.com/alibaba-rsocket-broker/ali-rsocket-graal-boot3-demo

Requirements

How to run

$ # switch to GraalVM 22.3.0
$ mvn -Pnative -DskipTests clean package
$ ./target/ali-rsocket-graal-demo
$ # open a new tab
$ curl http://localhost:8183/user/1

Native assist

For details, please refer: https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds

How to run app with native-image-agent mode?

$ mkdir -p target/native-image
$ java -agentlib:native-image-agent=config-output-dir=./target/native-image/ -jar target/ali-rsocket-graal-demo.jar

Then check assisted configurations under target/native-image/

Compress executable binary with upx

Compress GraalVM native image binary with UPX:

$ upx -7 -k target/ali-rsocket-graal-demo  

GraalVM Native Image guide

  • If you want to access remote RSocket Service, please add interface full name to proxy-config.json, then add .nativeImage() to create service call stub.
    @Bean
    public UserService userService(UpstreamManager upstreamManager) {
        return RSocketRemoteServiceBuilder
                .client(UserService.class)
                .upstreamManager(upstreamManager)
                .nativeImage()
                .build();
    }
  • If you want to publish RSocket Service, please add interface & implementation to reflection-config.json

References

Releases

No releases published

Packages

No packages published