"Класс CurrencyServiceClient имеет аннотации [ReactiveFeignClient], которые не используются контрактом Default" и "Метод getCurrencyDefinition имеет аннотацию GetMapping, которая не используется контрактом Default".
Я не уверен, что я не настроил правильно в своем микросервисе.
Ниже показано мой код:
- ReactiveFeignClient из валютного сервиса
Код: Выделить всё
@ReactiveFeignClient(
configuration = CurrencyServiceInternalClientConfiguration.class,
value = "currency-service",
path = "/currency-service/internal"
)
public interface CurrencyServiceClient {
@GetMapping(path = "/users/{userId}/balances/{currencyId}")
Mono getUserBalance(@PathVariable("userId") String userId,
@PathVariable("currencyId") Long currencyId);
@GetMapping(path = "/currencies")
Mono getCurrenciesDefinition(@RequestParam(value = "userId", required = false) Optional userId); ```
- служба, в которой реактивный ложный клиент используется в другой микрослужбе
Код: Выделить всё
@RequiredArgsConstructor
@Service
@Slf4j
public class CurrenciesService {
private final CurrencyServiceClient currencyServiceClient;
public CompletableFuture getCurrencies() {
List currenciesList = new ArrayList();
return currencyServiceClient.getCurrenciesDefinition(Optional.empty())
.toFuture()
.thenCompose(currenciesResponse -> {
currenciesResponse.getCurrencies().stream().forEach(currency -> {
Long currentTimestamp = Instant.now().getMillis();
if (currency.getResetTimestamp() CurrenciesResponse.builder()
.status(ResponseStatus.ERROR)
.build());
}
}
- конфигурация
Код: Выделить всё
@Configuration
@AutoConfigureAfter(ReactiveFeignAutoConfiguration.class)
@ConditionalOnProperty(prefix = "currency-service.client", name = "enabled", havingValue = "true",matchIfMissing = false)
@EnableReactiveFeignClients(clients = CurrencyServiceClient.class)
public class CurrencyClientAutoConfiguration {
}
- другие свойства
Код: Выделить всё
feign:
hystrix:
enabled: true
currency-service:
client:
enabled: true
eager-load:
clients: currency-service
enabled: true
Подробнее здесь: https://stackoverflow.com/questions/738 ... t-that-are