Skip to content

Latest commit

 

History

History
114 lines (74 loc) · 4.97 KB

README.adoc

File metadata and controls

114 lines (74 loc) · 4.97 KB

Vert.x JPMS examples

Here you will find examples demonstrating how Vert.x can be used with the Java Platform Module System (JPMS).

You can run tests from IDE or from an application image generated by jlink.

An application image is generated by the Apache Maven JLink Plugin when packaging the project with Maven (notice the jlink package in pom.xml), you can find the image in target/maven-jlink/default

Note
the io.netty.resolver.dns.classes.macos and io.netty.resolver.dns.macos.osx.aarch_64 are only useful on Mac/M1

HTTP/1.1 Server

A simple HTTP/2 server

You can run the server in your IDE and then curl http://localhost:8080.

You can also run the application image (Mac/M1):

./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.http.Server

HTTP/2 Server

A simple HTTP/2 server

You can run the server in your IDE and then curl -k https://localhost:8443.

You can also run the application image (Mac/M1):

./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.http2.Server

gRPC Service

A simple gRPC service

To run this example, you need to set the env variable TEMORARILY_DISABLE_PROTOBUF_VERSION_CHECK to true because the project uses a modified JPMS compliant Protobuf/Guava versions from JPMS Attic Repository.

You can run the server in your IDE and then grpcurl -plaintext -d '{"name":"Julien"}' -proto src/main/proto/helloworld.proto localhost:8080 helloworld.Greeter/SayHello.

You can also run the application image (Mac/M1):

# Required because we use 4.26.1-jpms dependency
export TEMORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true # yes there is a typo ...

./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.grpc.Server

Native transports

A simple HTTP server running with Netty native transports kqueue/epoll/io_uring.

To run this example in the IDE, you need to add transport/OS/architecture specific modules:

  • it can be added to the module-info.java declarations

  • io.netty.transport.classes.${native.transport}

  • io.netty.transport.${native.transport}.${os.detected.name}.${os.detected.arch}

  • or to the JVM launch command: --add-modules io.netty.transport.classes.${native.transport},io.netty.transport.${native.transport}.${os.detected.name}.${os.detected.arch}

You can also run the application image (Mac/M1):

// Add to module-info.java
requires io.netty.transport.classes.kqueue;
requires io.netty.transport.kqueue.osx.aarch_64;

Or launch the JVM with --add-modules io.netty.transport.classes.kqueue,io.netty.transport.kqueue.osx.aarch_64:

./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64,io.netty.transport.classes.kqueue,io.netty.transport.kqueue.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.native_transport.Server

Open SSL

A simple HTTP server using Netty OpenSSL.

To run this example in the IDE, you need to add OS/architecture specific modules:

  • it can be added to the module-info.java declarations

  • io.netty.tcnative.classes.openssl

  • io.netty.internal.tcnative.openssl.${os.detected.name}.${os.detected.arch}

  • or to the JVM launch command: --add-modules io.netty.transport.classes.${native.transport},io.netty.transport.${native.transport}.${os.detected.name}.${os.detected.arch}

You can also run the application image (Mac/M1):

// Add to module-info.java
requires io.netty.tcnative.classes.openssl;
requires io.netty.internal.tcnative.openssl.osx.aarch_64;

Or launch a JVM with --add-modules io.netty.tcnative.classes.openssl,io.netty.internal.tcnative.openssl.osx.aarch_64:

./target/maven-jlink/default/bin/java --add-modules io.netty.resolver.dns.classes.macos,io.netty.resolver.dns.macos.osx.aarch_64,io.netty.tcnative.classes.openssl,io.netty.internal.tcnative.openssl.osx.aarch_64 --module jpms.examples/io.vertx.example.jpms.openssl.Server

Sql Client

A simple client accessing the PostgreSQL database.

Since it requires a database, you can run it from a JUnit5 test