title: Spring Boot WebClient Connection and Read Timeout
body: <p>Currently my post and get requests are handled through WebClients which has a common connection and read timeout in Spring Boot. I have 5 different classes each requiring its own set of connection and read timeout. I don't want to create 5 different WebClients, rather use the same Webclient but while sending a post or a get request from a particular class, specify the required connection and read timeout. Is there any way to implement this?</p>
  <p>My current WebClient:</p>
  <pre><code>    @Bean
      public WebClient getWebClient(WebClient.Builder builder){
  
          HttpClient httpClient = HttpClient.newConnection()
                  .tcpConfiguration(tcpClient -&gt; {
                      tcpClient = tcpClient.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeout*1000);
                      tcpClient = tcpClient.doOnConnected(conn -&gt; conn
                              .addHandlerLast(new ReadTimeoutHandler(readTimeout, TimeUnit.SECONDS)));
                      return tcpClient;
                  }).wiretap(true);
  
          ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
  
          return builder.clientConnector(connector).build();
      }
  </code></pre>
  <p>A post request I'm using:</p>
  <pre><code>public WebClientResponse httpPost(String endpoint, String requestData, Map&lt;String, Object&gt; requestHeader) {
  
          ClientResponse res = webClient.post().uri(endpoint)
                  .body(BodyInserters.fromObject(requestData))
                  .headers(x -&gt; {
                      if(requestHeader != null &amp;&amp; !requestHeader.isEmpty()) {
                          for (String s : requestHeader.keySet()) {
                              x.set(s, String.valueOf(requestHeader.get(s)));
                          }
                      }
                  })
                  .exchange()
                  .doOnSuccess(x -&gt; log.info(&quot;response code = &quot; + x.statusCode()))
                  .block();
  
          return convertWebClientResponse(res);
      }
  </code></pre>