Reputation: 55
I have an abstract class
public abstract class A {
public String makeSomething(String ingredients){
throw new RuntimeException("Can't Make anything");
}
}
This class is realised in another class B(Spring Service) which uses makeSomething in many of its own methods by passing Ingredients. Each method in class B is annotated with HystrixCommand and a fallback has been defined for it. Here is what it looks like
@Service
public class B extends A {
@HystrixCommand(fallbackMethod = "doNothing")
public void makeTea(String ingredients){
makeSomething(ingredients);
}
public void doNothing(String ingredients){
System.out.println("Doing Nothing");
}
}
Now when makeTea from class B is invoked, it inturn calls makeSomething from class A which then throws exception. This should be wrapped as HystrixRuntimeException and then fallback should be invoked. But I am seeing RunTimeException("Can't Make anything").
Upvotes: 3
Views: 1777
Reputation: 1460
Based on your description, I would say, Hystrix is not enabled.
Add @EnableHystrix
annotation to your Application class, so annotation processing is enabled.
If you have it enabled, please provide a more complete example, where the error can be reproduced.
Upvotes: 2