Hystrix 명령을 클래스로 정의한 경우 그룹 키와 명령 키를 정의하는 것을 제어 할 수 있습니다. Feign Hystrix 명령 이름이 작동하지 않습니다.
private static class MyHystrixCommand extends HystrixCommand<MyResponseDto> {
public MyHystrixCommand() {
super(HystrixCommandGroupKey.Factory.asKey("MyHystrixGroup"));
}
그래서 위의 코드 그룹 키를 MyHystrixGroup하고 명령 키는 MyHystrixCommand입니다.
내가이 hystrix 명령의 구성을 설정하려면 내가
ConfigurationManager.getConfigInstance().setProperty(
"hystrix.command.MyHystrixCommand.execution.timeout.enabled", false);
같이 할 수있는 경우 기본 사람이 될 수있는 바와 같이, 이제
ConfigurationManager.getConfigInstance().setProperty(
"hystrix.command.default.execution.timeout.enabled", false);
나는 척하기 Hystrix를 사용하고, I 명령 이름/그룹 이름을 정의하지 않았습니다. 문서 here에 따라 그룹 키는 대상 이름과 일치하고 명령 키는 로깅 키와 동일합니다. 나는이 같은 FeignClient이 그렇다면
,
interface TestInterface {
@RequestLine("POST /")
String invoke() throws Exception;
}
나는 팩토리 클래스 내 척하기 클라이언트의 인스턴스를 만듭니다.
class TestFactory {
public TestInterface newInstance() {
ConfigurationManager.getConfigInstance()
.setProperty("hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", 500);
return HystrixFeign.builder()
.target(TestInterface.class, "http://localhost:" + server.getPort(), (FallbackFactory) new FallbackApiRetro());
}
}
클라이언트를 반환하기 전에 확인한 것처럼 내 hystrix 명령의 시간 초과 구성을 설정하고 싶습니다.
나는 MockWebServer로 테스트 중이다. 내가 기본 hystrix의 paramater에 hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds
ConfigurationManager.getConfigInstance()
.setProperty("hystrix.command.invoke.execution.isolation.thread.timeoutInMilliseconds", 500);
이 작동하지 않았다
을 시간을 설정할 때@Test
public void fallbackFactory_example_timeout_fail() throws Exception {
server.start();
server.enqueue(new MockResponse().setResponseCode(200)
.setBody("ABCD")
.setBodyDelay(1000, TimeUnit.MILLISECONDS));
TestFactory factory = new TestFactory();
TestInterface api = factory.newInstance();
// as the timeout is set to 500 ms, this case should fail since i added 1second delay in mock service response.
assertThat(api.invoke()).isEqualTo("Fallback called : foo");
}
에만 노력하고 있습니다. 마찬가지로 그들 중 아무도 아래 값을 시도했다.
hystrix.command.TestInterface#invoke(String).execution.isolation.thread.timeoutInMilliseconds
hystrix.command.TestInterface#invoke.execution.isolation.thread.timeoutInMilliseconds
이유 내가 이해하지 못하는 downvote가있다. 나는이 문제를 2 일 동안 파악하기 위해 고심하고 있었고, 누군가가 유용 할 수 있기 때문에 나의 연구 결과가 나온 후에 이곳에 게시했다. 사람들이 downvote 때, 그들은 너무 이유를 제공하는 것이 좋습니다. –