-
Notifications
You must be signed in to change notification settings - Fork 52
HttpConnectionPool
业余布道师 edited this page Jun 29, 2018
·
1 revision
Use the HttpConnectionPool need instantiate PoolConfig
and Properties
For example, the following
/* poolConfig */
PoolConfig config = new PoolConfig();
config.setMaxTotal(20);
config.setMaxIdle(5);
config.setMaxWaitMillis(1000);
config.setTestOnBorrow(true);
/* properties */
Properties properties = new Properties();
properties.setProperty("httpUrl", "http://localhost:8888/xxx/xxxx");
properties.setProperty("httpMethod", "POST");
properties.setProperty("httpHeader", "Accept:*/*,Content-type:application/json");
/* connection pool */
HttpConnectionPool pool = new HttpConnectionPool(config, properties);
/* pool getConnection */
HttpURLConnection connection = pool.getConnection();
...
/* pool returnConnection */
pool.returnConnection(connection);
More configs see the Configuration wiki.