Search code examples
jax-rsquarkusquarkus-rest-client

Quarkus Jax-rs clients with external interfaces


I started playing around with Quarkus and its REST client. According to the documentation a Jax-RS annotated interface should be created and annotated further with @RegisterRestClient.

My issue is that I already have the JaxRS interfaces for the services I need to connect to, in an artifact provided by the server, which I can just import. Is there a way to use an already created external Jax-RS interface to create a service with? It seems so wrong to copy-paste the code for a perfectly good interface, when it has been so nicely served for me.


Solution

  • There's RestClientBuilder, which allows programmatic usage of JAX-RS interfaces. Assuming the JAX-RS interface is called HelloClient, you can do this:

    HelloClient client = RestClientBuilder.newBuilder()
        .baseUri(URI.create("http://localhost:8080"))
        .build(HelloClient.class);