在应用程序级别限制Spring WebClient调用 [英] Restrict Spring WebClient call at application level

查看:106
本文介绍了在应用程序级别限制Spring WebClient调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中使用Spring WebFlux和WebClient.

I am using Spring WebFlux and WebClient for my web application.

我的应用程序可能无法再由我们托管的其他微服务调用"N".

My application potentially can call 'N' no of other micro services which is again hosted by us.

现在的问题是我想限制我的WebClient调用对现有微服务的有限呼叫.

Now the problem is that i want to restrict my WebClient to invoke limited no of calls to existing micro services.

此外,我不想在单个呼叫级别上执行此操作,而是在应用程序级别上执行此操作.

Also, i don't want to do it at individual call level, but at application level.

我已经经历过&

I have already gone through this & this

推荐答案

您可以创建一个WebClient实例,如下所示:

You can create a WebClient instance like this:

ConnectionProvider fixedPool = ConnectionProvider.fixed("fixedPool", maxConnections, acquireTimeout);
HttpClient httpClient = HttpClient.create(fixedPool);
WebClient webClient = WebClient.builder()
     .clientConnector(new ReactorClientHttpConnector(httpClient)).build();

这篇关于在应用程序级别限制Spring WebClient调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆