Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 2.89 KB

File metadata and controls

97 lines (73 loc) · 2.89 KB

MyServiceBus Java

This folder contains the Java modules for MyServiceBus. The Gradle multi-project build resides at the repository root.

Prerequisites

  • JDK 17 (Temurin/OpenJDK recommended)
  • Gradle
  • Docker (optional) to run RabbitMQ locally

Build

If the Gradle wrapper JAR is missing, bootstrap it from the repository root:

gradle wrapper
  • From the repository root, build all modules and run tests:
    ./gradlew test

Run locally

1) Start RabbitMQ

From the repository root, start RabbitMQ using Docker Compose:

docker compose up -d rabbitmq

RabbitMQ defaults: host localhost, port 5672, mgmt UI http://localhost:15672 (guest/guest).

2) Run the Test App

  • From the module directory:
    cd src/Java/testapp
    RABBITMQ_HOST=localhost HTTP_PORT=5301 ../../gradlew run
  • From the repo root (no cd required):
    RABBITMQ_HOST=localhost HTTP_PORT=5301 ./gradlew -p src/Java/testapp run

Helper script (equivalent):

cd src/Java/testapp
RABBITMQ_HOST=localhost HTTP_PORT=5301 ./run.sh

The app starts an HTTP server (default port 5301) with routes:

  • GET /publish – publishes SubmitOrder
  • GET /send – sends SubmitOrder to a queue
  • GET /request – request/response demo
  • GET /request_multi – request/response with Fault handling`

Run multiple instances by changing HTTP_PORT (e.g., 5301 and 5302).

Environment variables

  • RABBITMQ_HOST: RabbitMQ host (default localhost)
  • HTTP_PORT: HTTP port for testapp (default 5301)

Aspire and OpenTelemetry

To run the Java test app under Aspire, two things must be true:

  1. The OpenTelemetry Java agent JAR must exist at src/AspireApp/agents/opentelemetry-javaagent.jar.
  2. A trusted Aspire OTLP certificate PEM must exist at src/AspireApp/agents/aspire-localhost-cert.pem.
  3. The test app JAR must be built before the AppHost starts.

Build the executable JAR from the repository root:

./gradlew :testapp:jar

Set up the Java agent:

mkdir -p src/AspireApp/agents
curl -fL \
  https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar \
  -o src/AspireApp/agents/opentelemetry-javaagent.jar

The AppHost also configures the Java agent to trust a local Aspire OTLP certificate PEM at:

src/AspireApp/agents/aspire-localhost-cert.pem

Then start Aspire:

dotnet run --project src/AspireApp/AspireApp.csproj

Additional details are documented in docs/development/aspire-java-telemetry.md.

See also: docs/two-service-sample.md for running .NET and Java together.

Notes

  • Lombok is configured as an annotation processor via the root build.gradle and does not need to be added per-module.
  • Modules and external dependency versions are centralized in the root build.gradle.