I'm trying to use hyst however when calling the save method, which makes a post with resttemplate, gives the following exception:
com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionException: fallback method wasn't found: breaker([class com.wnb.mastercard.domain.enroll.EnrollCommand])
Can someone help me?
@Component
public class EnrollRepositoryRest {
@Autowired
private RestTemplate template;
@Value("${beblue-card-enroll.url}")
private String url;
public Enroll getEnrollByCardId(String cardId) {
Enroll[] enroll = template.getForObject(url + "cardEnroll/enroll/" + cardId, Enroll[].class);
return enroll[0];
}
@HystrixCommand(fallbackMethod = "breaker")
public void save(EnrollCommand command) {
template.postForObject(url + "/cardEnroll/enroll", command, EnrollCommand.class);
}
public String breaker() {
System.out.println("HYSTRIX EXECUTADO");
return "Hystrix is Ok";
}
}
I think the exception is clearly telling you the issue. The method:
public String breaker(EnrollCommand command) {
System.out.println("HYSTRIX EXECUTADO");
return "Hystrix is Ok";
}
Does not exist. (Notice the argument in the signature)
When you define a fallback method with that annotation the fallback method must match the same parameters of the method where you define the Hystrix Command.