@ -29,6 +29,8 @@ import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient ;
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients ;
import org.springframework.http.HttpHeaders ;
import org.springframework.util.unit.DataSize ;
import org.springframework.web.reactive.function.client.ExchangeStrategies ;
import org.springframework.web.reactive.function.client.WebClient ;
/ * *
@ -52,6 +54,7 @@ public class ReactiveRestClientAutoConfiguration {
builder . usingSsl ( ) ;
}
configureTimeouts ( builder , properties ) ;
configureWebClient ( builder , properties ) ;
return builder . build ( ) ;
}
@ -67,6 +70,19 @@ public class ReactiveRestClientAutoConfiguration {
} ) ;
}
private void configureWebClient ( ClientConfiguration . TerminalClientConfigurationBuilder builder ,
ReactiveRestClientProperties properties ) {
PropertyMapper map = PropertyMapper . get ( ) ;
builder . withWebClientConfigurer ( ( webClient ) - > {
ExchangeStrategies exchangeStrategies = ExchangeStrategies . builder ( )
. codecs ( ( configurer ) - > map . from ( properties . getMaxInMemorySize ( ) ) . whenNonNull ( )
. asInt ( DataSize : : toBytes )
. to ( ( maxInMemorySize ) - > configurer . defaultCodecs ( ) . maxInMemorySize ( maxInMemorySize ) ) )
. build ( ) ;
return webClient . mutate ( ) . exchangeStrategies ( exchangeStrategies ) . build ( ) ;
} ) ;
}
@Bean
@ConditionalOnMissingBean
public ReactiveElasticsearchClient reactiveElasticsearchClient ( ClientConfiguration clientConfiguration ) {