Quarkus JSON-RPC
Expose your Java methods as JSON-RPC 2.0 endpoints over WebSocket — with a single annotation.
Quarkus JSON-RPC discovers classes annotated with @JsonRPCApi at build time and makes their public methods callable via the JSON-RPC 2.0 protocol over a WebSocket connection. No manual routing, no protocol plumbing.
In a Glance
@JsonRPCApi
public class GreetingService {
public String hello(String name) {
return "Hello " + name;
}
}
Connect to ws://localhost:8080/quarkus/json-rpc and send:
{
"jsonrpc": "2.0",
"id": 1,
"method": "GreetingService#hello",
"params": { "name": "World" }
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": "Hello World"
}
Installation
Add the extension to your project:
<dependency>
<groupId>io.quarkiverse.json-rpc</groupId>
<artifactId>quarkus-json-rpc</artifactId>
<version>0.0.5</version>
</dependency>
Key Features
- Build-time discovery
-
All
@JsonRPCApiclasses are found at build time via Jandex — no runtime classpath scanning, full ahead-of-time compilation and GraalVM native image support. - Reactive and blocking
-
Return plain types for blocking execution,
Uni<T>for async, orMulti<T>for streaming subscriptions. Fine-tune with@Blockingand@NonBlocking. - Server push
-
Inject
JsonRPCBroadcasterto send notifications to all connected clients or target a specific session. - Flexible parameters
-
Call methods with named parameters (JSON object) or positional parameters (JSON array).
- POJO support
-
Complex types are serialized and deserialized automatically via Jackson, including nested objects, collections, and Java time types.
- Security
-
Secure your endpoints with standard Jakarta security annotations (
@RolesAllowed,@Authenticated, etc.) or Quarkus HTTP auth policies — opt-in, no changes needed for unsecured use cases. - JavaScript client
-
Optionally generate a typed JavaScript proxy for all your endpoints, ready to import from Quarkus Web Bundler or any ES module environment.
- Dev UI
-
An interactive method browser and tester is available in the Quarkus Dev UI during development.
What’s Next?
| Page | Description |
|---|---|
Annotate your first class and understand method discovery rules. |
|
Blocking, non-blocking, |
|
Named vs. positional parameters and supported types. |
|
Subscribe to server-sent streams and manage subscriptions. |
|
Push notifications to clients from any CDI bean. |
|
Secure endpoints with annotations or HTTP auth policies. |
|
Connection isolation, shared bean instances, threading model, and tuning for production. |
|
Generate a typed JavaScript proxy for calling your endpoints from the browser. |
|
All available configuration properties. |