ReactiveException: java.lang.InterruptedException, когда я отмечаю метод с помощью @HystrixCommand

У меня есть следующий метод:

    @Timed(value = "my.request.timer", percentiles = {0.5, 0.95}, histogram = true)
    public ResponseEntity<MyResponseDto> executeHttpCall(MyReq myReq) {
        log.warn("!!!!! REAL METHOD!!!! for {}", myReq);
        Mono<ResponseEntity<MyResponseDto>> responseEntityMono = webClient.post()
                .bodyValue(myReq)
                .retrieve()
                .toEntity(MyResponseDto.class);
        try {
            return responseEntityMono.block();
        } catch (Exception e) {
            log.warn("EXCEPTION: ", e);
        }
        return null;
    }

Я хотел добавить hystrix для этого метода, поэтому получил следующее:

   @HystrixCommand(fallbackMethod = "nullResponse",
        threadPoolProperties = {
                @HystrixProperty(name = "coreSize", value = "1000"),
               @HystrixProperty(name = "maxQueueSize", value = "7777"),
        })
   @Timed(value = "my.request.timer", percentiles = {0.5, 0.95}, histogram = true)
    public ResponseEntity<MyResponseDto> executeHttpCall(MyReq myReq) {
        log.warn("!!!!! REAL METHOD!!!! for {}", myReq);
        Mono<ResponseEntity<MyResponseDto>> responseEntityMono = webClient.post()
                .bodyValue(myReq)
                .retrieve()
                .toEntity(myResponseDto.class);
        try {
            return responseEntityMono.block();
        } catch (Exception e) {
            log.warn("EXCEPTION: ", e);
        }
        return null;
    }

public ResponseEntity<MyResponseDto> nullResponse(MyReq myReq) {
    log.warn("Fallback method invoked for {}", myReq);
    fallbackMethodIvocationCount.increment();
    return null;
}

Стало причиной ошибки(иногда воспроизводится, а иногда нет)

2019-11-11 17:33:51.954  WARN 2996 --- [ConnectorImpl-9] b.m.a.p.MyDetectorAPIConnectorImpl : EXCEPTION: 

2019-11-11 17:33:51.954  WARN 2996 --- [ConnectorImpl-9] b.m.a.p.MyDetectorAPIConnectorImpl : EXCEPTION: 

reactor.core.Exceptions$ReactiveException: java.lang.InterruptedException
    at reactor.core.Exceptions.propagate(Exceptions.java:336)
    at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:85)
    at reactor.core.publisher.Mono.block(Mono.java:1663)
    at my.MyService.executeHttpCall(MyDetectorAPIConnectorImpl.java:89)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)

В чем может быть причина этой проблемы и как ее исправить?


person gstackoverflow    schedule 11.11.2019    source источник


Ответы (1)


Это было из-за тайм-аута по умолчанию hystrix. Можно отключить этот тайм-аут, чтобы использовать следующее свойство:

hystrix.command.default.execution.timeout.enabled: false
person gstackoverflow    schedule 11.11.2019