Is there a way to get the reason a HystrixCommand
failed when using the @HystrixCommand
annotation within a Spring Boot application? It looks like
I haven't found a way to get the exception with Annotations either, but creating my own Command worked for me like so:
public static class DemoCommand extends HystrixCommand {
protected DemoCommand() {
super(HystrixCommandGroupKey.Factory.asKey("Demo"));
}
@Override
protected String run() throws Exception {
throw new RuntimeException("failed!");
}
@Override
protected String getFallback() {
System.out.println("Events (so far) in Fallback: " + getExecutionEvents());
return getFailedExecutionException().getMessage();
}
}
Hopefully this helps someone else as well.