I am building a microservice which uses the Reactive Feign Client defined in another microservice in order to fetch some data. I added the configuration for the feign client, enabled reactive feign clients, but when I am running the program, I get:
"Class CurrencyServiceClient has annotations [ReactiveFeignClient] that are not used by contract Default" and "Method getCurrenciesDefinition has an annotation GetMapping that is not used by contract Default".
I am not sure what I did not configure right in my microservice. Below is my code:
- ReactiveFeignClient from currencies-service
@ReactiveFeignClient(
configuration = CurrencyServiceInternalClientConfiguration.class,
value = "currency-service",
path = "/currency-service/internal"
)
public interface CurrencyServiceClient {
@GetMapping(path = "/users/{userId}/balances/{currencyId}")
Mono<CurrencyBalanceResponse> getUserBalance(@PathVariable("userId") String userId,
@PathVariable("currencyId") Long currencyId);
@GetMapping(path = "/currencies")
Mono<CurrenciesResponse> getCurrenciesDefinition(@RequestParam(value = "userId", required = false) Optional<String> userId); ```
- service where reactive feign client is used in the other microservice
@RequiredArgsConstructor
@Service
@Slf4j
public class CurrenciesService {
private final CurrencyServiceClient currencyServiceClient;
public CompletableFuture<CurrenciesResponse> getCurrencies() {
List<Currency> currenciesList = new ArrayList<>();
return currencyServiceClient.getCurrenciesDefinition(Optional.empty())
.toFuture()
.thenCompose(currenciesResponse -> {
currenciesResponse.getCurrencies().stream().forEach(currency -> {
Long currentTimestamp = Instant.now().getMillis();
if (currency.getResetTimestamp() <= currentTimestamp) {
currenciesList.add(Currency.builder().id(currency.getId())
.name(currency.getName()).build());
}
});
return CompletableFuture.completedFuture(CurrenciesResponse.builder()
.status(ResponseStatus.SUCCESS)
.currencies(currenciesList)
.build());
})
.exceptionally(exception -> CurrenciesResponse.builder()
.status(ResponseStatus.ERROR)
.build());
}
}
- configuration
@Configuration
@AutoConfigureAfter(ReactiveFeignAutoConfiguration.class)
@ConditionalOnProperty(prefix = "currency-service.client", name = "enabled", havingValue = "true",matchIfMissing = false)
@EnableReactiveFeignClients(clients = CurrencyServiceClient.class)
public class CurrencyClientAutoConfiguration {
}
- other properties
feign:
hystrix:
enabled: true
currency-service:
client:
enabled: true
eager-load:
clients: currency-service
enabled: true
Can anyone help?