public Set<Annotation> getInterceptorBindings() {
if (interceptorBindings == null)
interceptorBindings = new HashSet<>();
return interceptorBindings;
}
And on the create() method, introduce the InterceptionFactory if the interceptor binding set is not empty. That way, each RI of FT can introduce its interceptor binding annotations to the said bean.
SmallRye: @FaultToleranceBinding
Helidon: @CommandBinding
Apache: @Safeguard
With this approach, it can propagate to RestClient as well.
Alternatively, try a use a service loader that provides a mean to register our bean, ready for interception.
Thoughts?
This comes from implementing Fault Tolerance to Langchain4J AI Services
Code: https://github.com/langchain4j/langchain4j-cdi/blob/main/langchain4j-cdi-fault-tolerance/src/main/java/dev/langchain4j/cdi/faulttolerance/spi/Langchain4JFaultToleranceExtension.java
The CDI Bean in question: https://github.com/langchain4j/langchain4j-cdi/blob/main/langchain4j-cdi-portable-ext/src/main/java/dev/langchain4j/cdi/core/portableextension/LangChain4JAIServiceBean.java
Thanks.
Hi everyone,Here's the dilemma that I believe we need to view.Suppose you have an interface, SomeInterface, that generates a proxy through a factory and is now registered for CDI scoping and injection.
Now, suppose this SomeInterface has a @Retry Fault Tolerance mechanism applied to a method.
Currently, the Fault Tolerance interceptor (from any Reference Implementation of FT) won't trigger since it's not a CDI managed bean (concrete implementation). The proxy has no way of inheriting the @Retry annotation from the interface SomeInterface.
This is the same problem why RestClient cannot be applied with Fault Tolerance mechanism.
A solution is to use InterceptorFactory, as follows:
InterceptionFactory<T> factory = beanManager.createInterceptionFactory(creationalContext, aiServiceInterfaceClass); factory.configure().add(new InterceptorBindingLiteral()); instance = factory.createInterceptedInstance(instance); Now, this requires that you know the Interceptor binding annotation from your MP compatible Application server (whether it runs Helidon FT, SmallRye FT, Apache Safeguard, etc.).
Now, Quarkus have figured out a way to make this problem work, but for the rest, not so much.
I suggest that we introduce the getInterceptorBinding() method to the CDI `Bean` interface, e.g.,public Set<Annotation> getInterceptorBindings() {
if (interceptorBindings == null)
interceptorBindings = new HashSet<>();
return interceptorBindings;
} And on the create() method, introduce the InterceptionFactory if the interceptor binding set is not empty.
That way, each RI of FT can introduce its interceptor binding annotations to the said bean.
SmallRye: @FaultToleranceBinding
Helidon: @CommandBindingApache: @Safeguard
With this approach, it can propagate to RestClient as well.
Alternatively, try a use a service loader that provides a mean to register our bean, ready for interception.
Thoughts?
This comes from implementing Fault Tolerance to Langchain4J AI Services
Code: https://github.com/langchain4j/langchain4j-cdi/blob/main/langchain4j-cdi-fault-tolerance/src/main/java/dev/langchain4j/cdi/faulttolerance/spi/Langchain4JFaultToleranceExtension.java
The CDI Bean in question: https://github.com/langchain4j/langchain4j-cdi/blob/main/langchain4j-cdi-portable-ext/src/main/java/dev/langchain4j/cdi/core/portableextension/LangChain4JAIServiceBean.java
To view this discussion visit https://groups.google.com/d/msgid/microprofile/CALbocOn2DS2Oku7TJ2i0%3DFzc1gR%2BR6ijBPMBaaO4aK%3D382D%2BEw%40mail.gmail.com.
Thanks Ladislav,The problem is that some of these interception binding annotations are package private (ahem, Helidon). Bean implementation aside, the solution should, ideally, allow to be linked to any interceptor during bean registration.
Also, this solution does not work (as to my knowledge) when using Build Compatible Extension (introduced in CDI 4).
It should be that developers shouldn't choose what type of FT RI they should use in their projects to enable FT if the app server runtime already supports it. By introducing such features in the spec, providers can register their interceptor bindings and this can be used for triggering InterceptionFactory.
To view this discussion visit https://groups.google.com/d/msgid/microprofile/CABUp4f558MUGEtyJLyO%2BKMk9KrHXpFyXROWaRHmpBVprZSrfVw%40mail.gmail.com.
Dne so 14. 6. 2025 11:29 uživatel Buhake Sindi <buh...@gmail.com> napsal:Thanks Ladislav,The problem is that some of these interception binding annotations are package private (ahem, Helidon). Bean implementation aside, the solution should, ideally, allow to be linked to any interceptor during bean registration.Sorry, I still don't understand why you're focusing on there implementation details. I might be missing something, but what's wrong with scanning the interface for all the interceptor binding annotations you need (all the FT annotations are interceptor bindings) and copying them to the InterceptionFactory? That should work, no?
You received this message because you are subscribed to a topic in the Google Groups "MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/lto5IHWkN1A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/microprofile/CALbocO%3DPwNWg%3DRwrn4E1-EpAPwHm%2B_JJY2jTtwhek05oRpGnUg%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/microprofile/039eb80e-f3cb-40c4-8028-f12366a01f4en%40googlegroups.com.