Im using threads to make API Requests with Webclient and I want to roatate proxies with every request. I've seen multiple examples using Resttemplate but cannot find one with Webclient.
This function uses the Webclient:
public BigDecimal call() throws Exception {
String proxyServer = getNextProxy();
InetSocketAddress proxyAddress = new InetSocketAddress(proxyServer, 8080); // Adjust port as needed
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
WebClient webClient = WebClient.create();
BigDecimal priceAvg = BigDecimal.ZERO;
int goodsId = goodsList.stream().filter(good -> good.getName().equals(item.getMarket_hash_name())).findFirst().get().getId();
log.info("Accessing API Endpoint");
String apiUrl = "--url--";
Mono<String> responseEntity = webClient.get()
.uri(buff163Api + goodsId)
.retrieve()
.bodyToMono(String.class);
}
Keep in mind, I have no clue about Proxies with Webclient, the first three lines of code are from ChatGPT.
Any help or useful resources would be very appreciated.