【问题标题】:nested exception is org.springframework.web.reactive.function.client.WebClientResponseException:嵌套异常是 org.springframework.web.reactive.function.client.WebClientResponseException:
【发布时间】:2023-02-06 09:36:06
【问题描述】:

我从应用程序调用另一个微服务,当数据更多时,我得到以下异常

nested exception is org.springframework.web.reactive.function.client.WebClientResponseException: 200 OK from GET https://ops-service.apps.com/api/v1/ops/list?page-size=150&page-offset=0; nested exception is org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144] with root cause
org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
    at org.springframework.core.io.buffer.LimitedDataBufferList.raiseLimitException(LimitedDataBufferList.java:99) ~[spring-core-5.3.15.jar:5.3.15]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):

我试图通过如下尝试解决上述异常,但没有成功,但仍然出现异常。 在两个微服务的 application.properties 中包含以下行。

spring.codec.max-in-memory-size=70MB

任何人都有上述异常的解决方案?

【问题讨论】:

    标签: java spring


    【解决方案1】:

    您需要定义一个自定义 bean,如下所示:

    @Bean("webClient")
    public WebClient customWebClient(WebClient.Builder builder) {
        return builder.baseUrl(host).build();
    }
    

    或者,

    @Bean("webClient")
        public WebClient customWebClient() {
            return WebClient
              .builder()
              .baseUrl(host)
              .exchangeStrategies(ExchangeStrategies
          .builder()
          .codecs(codecs -> codecs
                .defaultCodecs()
                .maxInMemorySize(size * 1024 * 1024))
            .build())
              .build();
    }
    

    学分: https://www.baeldung.com/spring-webflux-databufferlimitexception

    【讨论】:

      猜你喜欢
      • 2019-06-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多