Автоматический выключатель Hystrix не выбирает application.yml - PullRequest
0 голосов
/ 04 февраля 2019

Автоматический выключатель Hystrx не выбирает значения из файла application.yml.Мне нужно получить timeoutInMilliseconds, errorThresholdPercentage из файла application.yml.Когда я запускаю программу, эти свойства не влияют, потому что они не подобраны.

import java.net.URI;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class BookService {
      RestTemplate restTemplate;
      //Calling the service
     @HystrixCommand
      public String readingList(int flag) {
        restTemplate = new RestTemplate();
         URI uri = URI.create("http://localhost:8090/recommended/"+flag);
        return this.restTemplate.getForObject(uri, String.class);
      }

      public String reliable(int flag) {
        return "Cloud Native Java (O'Reilly)";
      }

}

Это файл application.yml

hystrix:
  command:
    reliable:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 6000
          strategy: SEMAPHORE
        circuitBreaker:
          errorThresholdPercentage: 70

1 Ответ

0 голосов
/ 04 февраля 2019

Вам необходимо аннотировать ваш метод с помощью @HystrixCommand () и указывать commandKey = "надежный".

@HystricCommand(commandKey="reliable")
public String reliable(int flag) {
    return "Cloud Native Java (O'Reilly)";
  }
...