我正在使用Apache PoolingHttpClientConnectionManager创建一个连接到我的网络上的差异服务的池.文档说,Connections是基于每个路由汇集的.我并不完全清楚路线的含义.
我发现了另一个similar问题,但答案仍然有点不清楚.如果我们在同一台服务器上有两个应用程序,每个应用程序都有多个REST API,那么每个API都被认为是一个不同的路径吗?
例如,如果我们有以下内容:
http://server1/app1/books
http://server1/app1/magazines
http://server1/app2/cars
http://server1/app2/cars/color/red
http://server1/app2/cars/color/black/doors/2
以上各项都被视为单一路线吗?
最佳答案:
PoolingHttpClientConnectionManager实现了ConnPoolControl< HttpRoute>,因此我们可以假设我们正在谈论的路由是HttpRoute.
在文档中,它写的是HttpRoute
The route for a request.
HttpRoute的构造函数之一是以下形式:
HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies, boolean secure, RouteInfo.TunnelType tunnelled, RouteInfo.LayerType layered)
看看RouteInfo.LayerType,我们看到:
The layering type of a route. Plain routes are established by
connecting or tunnelling. Layered routes are established by layering a
protocol such as TLS/SSL over an existing connection. Protocols can
only be layered over a tunnel to the target, or or over a direct
connection without proxies.
总之,在这种情况下,术语路由应该被理解为网络路由,而不是从您的问题的标记“路由”定义的从URL到控制器的映射.