Examples / Transport

Ping Pong (Maven)

myra-codec-transport-ping-pong-maven

Maven wrapper workflow for a ping/pong client and server using Myra Codec and Myra Transport.

Transport Maven Java 25 View source

Overview

This Maven version of the ping/pong demo generates a simple payload schema and runs server and client processes via exec:java. It highlights the same registered buffer and transport flow as the Gradle example.

Clone and run

  1. Install Java 25 and Git, then confirm the toolchain.

    java --version
  2. Clone the examples repository.

    git clone https://github.com/mvp-express/examples.git
  3. Move into the Maven ping pong example folder.

    cd examples/myra-codec-transport-ping-pong-maven
  4. Generate sources and the lock file.

    ./mvnw -q \
      -Dexec.mainClass=express.mvp.myra.codec.codegen.MyraCodegenCli \
      -Dexec.args="--schema src/main/resources/schemas/ping_pong.myra.yml --output src/main/java --lockfile src/main/resources/locks/ping_pong.myra.lock" \
      exec:java
  5. Start the server in one terminal.

    ./mvnw -q -DskipTests \
      -Dexec.mainClass=express.mvp.myra.examples.pingpong.PingPongServer \
      -Dexec.jvmArgs="--enable-preview --enable-native-access=ALL-UNNAMED" \
      compile exec:java
  6. Start the client in another terminal.

    ./mvnw -q -DskipTests \
      -Dexec.mainClass=express.mvp.myra.examples.pingpong.PingPongClient \
      -Dexec.jvmArgs="--enable-preview --enable-native-access=ALL-UNNAMED" \
      compile exec:java

If you are on Windows, use mvnw.cmd and keep each command on a single line.

Concepts highlighted

  • Codec generated Payload schema for ping and pong.
  • Maven exec workflow with explicit preview and native access flags.
  • Transport client and server running in separate terminals.
  • Registered buffer pools and NIO backend configuration.
  • Zero copy payload decode with flyweights.

Files to explore

  • src/main/resources/schemas/ping_pong.myra.yml
  • src/main/java/express/mvp/myra/examples/pingpong/PingPongServer.java
  • src/main/java/express/mvp/myra/examples/pingpong/PingPongClient.java

At a glance

  • Type: Codec + Transport
  • Build: Maven
  • Main: PingPongServer, PingPongClient
  • Schema: ping_pong.myra.yml
  • Ports: 127.0.0.1:9000
Open on GitHub

Learn more

See how transport setup works with io_uring and registered buffers.

Myra Transport Docs