MicroProfile REST Client with Quarkus REST¶
The restclient module declares a REST client interface for Quarkus
REST and returns Mutiny Uni values for ordinary responses. It also declares
an event-stream method that returns Multi.
Declare and configure the client¶
PostResourceClient
uses @RegisterRestClient(configKey = "post-service") and registers a response
exception mapper. It provides count, list, and by-ID methods, plus an events
endpoint annotated for server-sent events.
The module configures the client URL and listens on port 8081:
quarkus.http.port=8081
quarkus.rest-client.post-service.url=http://localhost:8080
quarkus.rest-client.post-service.scope=jakarta.inject.Singleton
The POM includes quarkus-rest-client and
quarkus-rest-client-jackson. See Jackson on REST
clients.
Run the client¶
Start a posts service on port 8080, then run the client from
restclient:
./mvnw quarkus:dev
On Windows, run mvnw.cmd quarkus:dev.
What's next¶
- Compare
CompletionStagein the RESTEasy Classic client. - See MicroProfile REST Client with Kotlin coroutines.