MAMS examples
The downloadable projects below incorporate the scenarios from mams-guide into the ASTRA user guide. They use ASTRA 2.6.1, MAMS 2.4.1 and Java 17 or later. Start with Your first MAMS service, then work through the examples below.
Each archive contains a complete Maven project: its POM, ASTRA sources, Java data classes and, where applicable, example HTTP requests. Unzip it, open a terminal in the extracted project directory and run:
mvn clean compile astra:run
Leave a server running while you make requests from another terminal. Stop it with Ctrl+C before starting another example on port 9000. The HTTP client example uses its own port, 9001, and runs alongside the passive collection server.
Choose an example
Upstream example |
What it demonstrates |
Adapted project |
|---|---|---|
Java-Types passive |
An item, HTTP replacement and an agent notification |
|
Java-Types passive |
A collection and the lifecycle of its children |
|
Java-Types passive |
An ASTRA agent consumes another service through HTTP |
|
Java-Types passive |
Two agents interact through resource creation |
|
Java-Types passive |
An agent computes and publishes a result |
|
Java-Types active |
The agent accepts reads and refuses writes |
|
Java-Types active |
A policy covers a collection and its children |
|
HAL passive |
A linked resource representation |
|
MAMS 2.0.0 Hydra collection |
JSON-LD identities, members, discovery and writes |
Changes from the upstream examples
The adaptations follow the upstream guide at commit b5db2733fb61a459d5afc0e3701f94402b2b90da. The older guide identifies itself as MAMS 1.0.10. These projects update its Maven configuration and use the plan spelling used throughout this ASTRA guide.
The active examples install complete request policies because MAMS 2.4.1’s inherited Java-Types handler accepts requests by default. The collection example uses the standard Strings module instead of the older TempStrings helper, and avoids shadowing the inherited System module named S.
The ping-pong example explicitly announces that Pinger’s resources are ready before starting Ponger. The local client and ping-pong examples use a known loopback authority while preserving resource paths, avoiding unreachable JVM-resolved host addresses. The HAL example uses the current Java-Types representation converter with Accept: application/hal+json; the current MAMS source also retains the separate HAL artifact family.
The upstream-derived projects were recompiled and exercised against artifacts rebuilt from MAMS commit 280367e, using ASTRA 2.6.1. Runtime checks covered item read/update, active refusal, collection creation/read/update/deletion, the HTTP client sequence, ten-round ping-pong, a sum result of 9, and HAL links. The delivery tutorial was also rechecked. The Hydra example additionally checks JSON-LD writes, discovery routes and collection membership. Published dependencies are checked separately from rebuilt source artifacts.
Put the pieces together
Build a delivery service combines an active HTTP collection with a coordinator and internal courier agents, ordered progress publication and route failure recovery. Download its complete project.
See Deploying a MAMS Service for Java and container launch instructions, and Verifying the MAMS Examples for automated checks.
Custom resource creation
The custom counter project creates a ResourceArtifact directly, publishes agent-owned state and rejects unsupported writes. Follow Create a custom resource artifact for its source and HTTP checks.
Larger application case studies
These external projects show MAMS in a wider application. They have their own setup instructions and use earlier dependency versions; they are not included in the guide’s current example verifier.
Project |
What to explore |
|---|---|
A HAL service connects buyers and a seller to internal auction agents. The service currently declares ASTRA 2.0.8/MAMS 1.1.1, while buyer and seller declare ASTRA 1.4.2/MAMS 1.0.5. |
|
RDF discovery creates room agents that observe and control a simulated building. Its POM declares ASTRA 1.0.7 and MAMS HAL/Jena 0.3.0; running it also requires the BOLD server. |
Use the downloadable examples above for projects checked against the current guide versions. Treat these larger applications as separate case studies until their dependencies and APIs have been migrated and verified.