我正在使用RestClient
連接到遠程JSON API。 以前,在Spring 3.0中,我使用的是Commons HTTPClient。 由於舊式多線程連接管理器中的大量鎖定,我發現性能很低。爲Spring Web RestTemplate設置Apache HttpComponents PoolingClientConnectionManager
我現在想嘗試Apache HttpComponents 4.2,因爲它看起來他們固定了鎖定。 我想使用PoolingClientConnectionManager
作爲DefaultHttpClient
的構造函數參數,它將針對不同的類自動裝配。
挑戰在於設置PoolingClientConnectionManager
連接管理器。我想要大量的併發連接到JSON API提供程序。這些使用HttpRoute
對象來表示主機名。但是,如http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingClientConnectionManager.html中所述,PoolingClientConnectionManager
使用setMaxPerRoute(HttpRoute, int maxConnections)
方法。
如何設置連接管理器Spring的context.xml文件,因爲它不使用簡單的setter?