There's no way, currently, to apply Microprofile's fault tolerance interceptors to proxies.
E.g, with Microprofile RestClient, when creating a REST client Service interface (annotated with @RegisterRestClient) and add any MP Fault Tolerance interceptor annotations on a method, e.g., @Retry, the application container will never trigger it. That's because the "proxy" attached to the service is never spotted as a CDI bean, to link it to the SPI FT interceptor.
There's the same discussion I've raised with the Microprofile WG when we implemented Langchain4J-CDI (discussion here: https://groups.google.com/g/microprofile/c/lto5IHWkN1A).
I thought of introducing the following methods:
- Add the following on
BeanConfigurator interface: BeanConfigurator<T> addInterceptorBindings(Set<InterceptorBindings> interceptorBindings);.
- Add the following on
Bean interface: public Set<Annotation> getInterceptorBindings();.
This will require that when interceptor bindings annotations exists, the bean can be added to InterceptionFactory and return an intercepted instance of the proxy, else return the proxy.
This way, any SPI can register their custom InterceptorBindings annotations by adding their InterceptorBindings annotation and it'll guarantee to be intercepted.
For context, some SPI implementations are package-private so hacking a solution isn't possible (e.g., Helidon FT).
There's no way, currently, to apply Microprofile's fault tolerance interceptors to proxies.
E.g, with Microprofile RestClient, when creating a REST client
Serviceinterface (annotated with@RegisterRestClient) and add any MP Fault Tolerance interceptor annotations on a method, e.g.,@Retry, the application container will never trigger it. That's because the "proxy" attached to the service is never spotted as a CDI bean, to link it to the SPI FT interceptor.There's the same discussion I've raised with the Microprofile WG when we implemented Langchain4J-CDI (discussion here: https://groups.google.com/g/microprofile/c/lto5IHWkN1A).
I thought of introducing the following methods:
BeanConfiguratorinterface:BeanConfigurator<T> addInterceptorBindings(Set<InterceptorBindings> interceptorBindings);.Beaninterface:public Set<Annotation> getInterceptorBindings();.This will require that when interceptor bindings annotations exists, the bean can be added to
InterceptionFactoryand return an intercepted instance of the proxy, else return the proxy.This way, any SPI can register their custom
InterceptorBindingsannotations by adding theirInterceptorBindingsannotation and it'll guarantee to be intercepted.For context, some SPI implementations are package-private so hacking a solution isn't possible (e.g.,
Helidon FT).