How to override an interface fault tolerance annotation in application.properties

249 views Asked by At

I am trying to override an interface Timeout Fault tolerance annotation in application.properties. However I am not sure if it is possible to override annotation parameters via configuration file using property [classname/methodname/]annotation/parameter for an interface? Any idea what would be the syntax for interface?

Here is my ReST client Interface:

package com.myProject;

@RegisterRestClient(configKey = "test")
@Timeout
public interface MyInterface{
    @POST
    @Path("/my-endpoint")
    Uni<AResponse> create(ARequest request);
}

And here is my application.properties:

com.myProject.MyInterface/Timeout/value=2000

looking into the Quarkus dev UI dashboard, Timeout value is still 1000 which is the default value.

2

There are 2 answers

5
Jacouille On

Just set it in annotation

You could try setting it directly in the annotation value like this :

@Timeout(2000)

And override in application.properties if needed

According to SmallRye Fault Tolerance Documentation, you should be able to override value using one of these :

  • annotation-name/property-name=value
  • fully-qualified-class-name/method-name/annotation-name/property-name=value

Which in your case should be :

Timeout/value=2000

Or

com.myProject.MyInterface/create/Timeout/value=2000

Notice I only added method name create to the latest one

Edit

I believe you have to set your annotation @Timeout at the method level and add value like example above

package com.myProject;

@RegisterRestClient(configKey = "test")
public interface MyInterface{
    @POST
    @Timeout(2000)
    @Path("/my-endpoint")
    Uni<AResponse> create(ARequest request);
}
0
Narges Shojaedin On

Here is the answer to my question:

com.myProject.MyInterface$$CDIWrapper/Timeout/value=2000

This is exactly what can be seen in dev UI MyInterface$$CDIWrapper and I needed to use the same in the application.properties.