0

I have created some interface to a 3rd party service:

@RegisterRestClient
public interface FooService {
    @Path("/foo")
    @POST
    MyResponse foo(MyRequest request, @HeaderParam("X-Bla") String xBla);
    ...

This is working fine.

But then, I also want to create a "lite" version of the API. I was thinking of MyLiteFoo implements FooService, but I notice that all the annotations need to be redeclared in the implementing class since none are @Inherited?

Added: Can't even implements FooService because Quarkus will complain.

Or is there a simpler approach?

wiradikusuma
  • 1,930
  • 4
  • 28
  • 44
  • What do you mean by lite version?, quarkus rest-client is based on microprofile-rest-client which at far as i know should not be implemented because it aims to provide a implementation itself based on the annotations. Here you can check examples of usage and options available https://download.eclipse.org/microprofile/microprofile-rest-client-1.3/microprofile-rest-client-1.3.html – Javier Toja Jul 31 '21 at 09:18
  • Lite as in backup service that's hosted by my app when the 3rd party service is unavailable. – wiradikusuma Jul 31 '21 at 14:45
  • Ahh ok, for that you can use the microprofile-fault-tolerant apis, this will allow you to define a fallback mechanism for when the api is not responsive (503), or use retry policies. The fallback mechanism can be invoking other services or returning a default response. https://quarkus.io/guides/smallrye-fault-tolerance – Javier Toja Aug 02 '21 at 06:35
  • I haven't done that with JAX-RS for quite a while but it should work. What's the complaint of Quarkus if you do so? Is it about the `@RegisterRestClient` annotation on an interface that gets implemented? – Michał Szynkiewicz Aug 02 '21 at 11:09
  • @MichałSzynkiewicz that's correct. Quarkus doesn't like I Implement interface that supposed to be implemented internally by Quarkus. – wiradikusuma Aug 02 '21 at 12:57
  • I'd have to see the whole project to give a better advise but you can do e.g. have a common interface and then a sub-interface for the client, annotated with `@RegisterRestClient`. – Michał Szynkiewicz Aug 02 '21 at 13:53

0 Answers0