Back end
Modules are Java applications built on Quarkus. REST endpoints are written with JAX-RS, and asynchronous communication uses Vert.x.
Frameworks
| Framework | Role |
|---|---|
| Quarkus | Application framework designed for containers: fast startup and low memory use |
| JAX-RS | The Java standard for REST endpoints, with annotations such as @GET, @POST, @PUT and @DELETE |
| Vert.x | Reactive toolkit: non-blocking I/O, concurrent request handling and the event bus |
REST endpoints
A module exposes its services as JAX-RS resources, which browsers and other clients call over HTTP.
@Path("/api/items")
public class ItemResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAllItems() {
// Logic to retrieve items
return Response.ok(items).build();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response addItem(Item item) {
// Logic to add item
return Response.status(Response.Status.CREATED).build();
}
}
Asynchronous communication
Inside the platform, modules send and receive messages on the Vert.x event bus and run background work without blocking the calling thread.
@ApplicationScoped
public class ItemService {
@Inject
Vertx vertx;
public void sendMessage(String address, JsonObject message) {
vertx.eventBus().request(address, message, ar -> {
if (ar.succeeded()) {
// Handle successful response
} else {
// Handle failure
}
});
}
}
JAX-RS handles what comes in over HTTP; Vert.x handles what happens between modules. See Communication between modules.
MicroProfile
Quarkus implements MicroProfile, a set of open specifications for Java microservices. Modules rely on these parts of it:
| Specification | Use |
|---|---|
| Config | Settings that can be overridden without rebuilding |
| Fault Tolerance | Circuit breakers, timeouts and retries |
| JWT Propagation | Carrying the member's token between modules for authentication and authorization |
| Metrics | Performance metrics |
| OpenAPI | Documentation of the REST API |
| Health | Health checks used by the orchestrator |
| REST Client | Typed clients for calling other REST services |