Вот метод
@HystrixCommand(fallbackMethod = "GetData_Fallback")
@GetMapping("/currency-converter-feign/from/{from}/to/{to}/quantity/{quantity}") //where {from} and {to} represents the column
//returns a bean
public CurrencyConversionBean convertCurrencyFeign(@PathVariable String from, @PathVariable String to, @PathVariable BigDecimal quantity)
{
ExchangeValue response=proxy.retrieveExchangeValue(from, to);
logger.info("{}", response);
//creating a new response bean
//getting the response back and taking it into Bean
return new CurrencyConversionBean(response.getId(), from, to, response.getConversionMultiple(), quantity, quantity.multiply(response.getConversionMultiple()), response.getPort());
}
Вот запасной метод
@SuppressWarnings("unused")
private String GetData_Fallback(String from, String to,BigDecimal quantity) throws FallbackDefinitionException {
logger.error("Currency exchange Service is down!!! fallback route enabled...");
return "CIRCUIT BREAKER ENABLED!!! No Response From Currency exchange Service at this moment. " +
" Service will be back shortly - " + new Date();
Поскольку у запасного метода и основного метода разный тип возврата I ' Я получаю ошибку. Есть ли способ вернуть сообщение об ошибке? Я также попытался вызвать исключение вместо этого, но он печатает полную трассировку стека