In my MicroService I have to fetch data from places. Some of the URL's are fixed but some are not . So do I need to create WebClient
again and again if my base URL changes. If not then is the below way correct to create WebClient
.
WebClient.create();
and later is changing the URI
again and again whenever I make a call. As per my understanding creating a WebClient
must be some heavy operation.
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(
options -> options.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, requestTimeout).compression(true)
.afterNettyContextInit(ctx -> ctx.addHandlerLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS))));
return WebClient.builder()
.clientConnector(connector)
.baseUrl(hostURL)
.build();