Skip to content

Commit 2cce2c7

Browse files
committed
added the configuration section
1 parent fae8368 commit 2cce2c7

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/site/apt/configuring.apt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
------
2+
Async Http Client - Configuring the AsyncHttpClient
3+
------
4+
Jeanfrancois Arcand
5+
------
6+
2012
7+
8+
Configuring the AsyncHttpClient.
9+
10+
You can configure the <<<AsyncHttpClient>>> class using the <<<AsyncHttpClientConfig>>>'s Builder:
11+
12+
+-----+
13+
Builder builder = new AsyncHttpClientConfig.Builder();
14+
builder.setCompressionEnabled(true)
15+
.setAllowPoolingConnection(true)
16+
.setRequestTimesout(30000)
17+
.build();
18+
19+
AsyncHttpClient client = new AsyncHttpClient(builder.build());
20+
+-----+
21+
22+
You can set the ExecutorServices as well if you don't want to use the default, which is a cached threads pool:
23+
24+
+-----+
25+
Builder builder = new AsyncHttpClientConfig.Builder();
26+
builder.setExecutorService(myOwnThreadPool);
27+
AsyncHttpClient client = new AsyncHttpClient(builder.build());
28+
+-----+
29+
30+
You can also configure the connection pool the library is using and implement your own polling strategy:
31+
32+
+-----+
33+
Builder builder = new AsyncHttpClientConfig.Builder();
34+
builder.setConnectionsPool(new ConnectionsPoo<U,V>() {
35+
public boolean offer(U uri, V connection) {...}
36+
37+
public V poll(U uri) {...}
38+
39+
public boolean removeAll(V connection) {...}
40+
41+
public boolean canCacheConnection() {...}
42+
43+
public void destroy() {...}
44+
});
45+
AsyncHttpClient client = new AsyncHttpClient(builder.build());
46+
+-----+
47+
48+
It is recommended to use the default connections pool for performance reason, but you are always free to design a better one.
49+
50+
You can also set the SSL information, Filters, etc. Those topics will be covered inside their own section.

0 commit comments

Comments
 (0)