Spring boot version 3.2.5 and Java 17
I have one service say address service which has webclient builder bean which is used to call many different services hosted in same cloud environment say account, audit ,invoice etc these 3 services in turn calls various downstream systems using rest template builder.
declared bean as below for webclient builder in address service i am autowiring this bean in various service layer classes and calling account ,audit and invoice services which makes various downstream system calls in turn using rest template builder
`@Bean
WebClient webClient(WebClient.Builder builder) {
final ExchangeStrategies strategies = ExchangeStrategies.builder().codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(responseSize))
.build();
return builder.clientConnector(new ReactorClientHttpConnector(HttpClient.create())).exchangeStrategies(strategies).build();
}
@Bean(name="normalRestTemplate")
public RestTemplate restTemplate(RestTemplateBuilder builder) {
RestTemplate restTemplate = builder.build();
restTemplate.setRequestFactory(getClientHttpRequestFactory());
return restTemplate;
}`
This is rest template builder in invoice, account, audit
I am facing issue like multiple duplicate calls are made to downstream systems from invoice,account,audit where I am using rest template builder to call those systems why I am facing this issue.
I am returning mono response entity in webclient
I need only single calls to downstream how i can achieve