use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project tutorials by eugenp.
the class HttpClientConnectionManagementLiveTest method whenCustomizedIdleConnMonitor_thenNoExceptions.
@Test
public final // 8.2 ARTICLE VERSION
void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException {
new HttpGet("http://google.com");
poolingConnManager = new PoolingHttpClientConnectionManager();
client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager);
staleMonitor.start();
staleMonitor.join(1000);
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project tutorials by eugenp.
the class HttpClientConnectionManagementLiveTest method whenExecutingSameRequestsInDifferentThreads_thenExecuteReuqest.
@Test
public final // 4.2 Article version
void whenExecutingSameRequestsInDifferentThreads_thenExecuteReuqest() throws InterruptedException {
final HttpGet get = new HttpGet("http://www.google.com");
poolingConnManager = new PoolingHttpClientConnectionManager();
client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client, get);
final MultiHttpClientConnThread thread2 = new MultiHttpClientConnThread(client, get);
final MultiHttpClientConnThread thread3 = new MultiHttpClientConnThread(client, get);
thread1.start();
thread2.start();
thread3.start();
thread1.join();
thread2.join();
thread3.join();
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project tutorials by eugenp.
the class HttpClientConnectionManagementLiveTest method whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions.
// 3
@Test
public final // Example 3.1.
void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException, ClientProtocolException, IOException {
poolingConnManager = new PoolingHttpClientConnectionManager();
client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
client.execute(get1);
assertTrue(poolingConnManager.getTotalStats().getLeased() == 1);
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project tutorials by eugenp.
the class HttpClientConnectionManagementLiveTest method whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit.
@Test
public final /*tester*/
void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit() throws InterruptedException, IOException {
poolingConnManager = new PoolingHttpClientConnectionManager();
client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager);
final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager);
final TesterVersion_MultiHttpClientConnThread thread3 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager);
thread1.start();
thread2.start();
thread3.start();
thread1.join(10000);
thread2.join(10000);
thread3.join(10000);
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project microservice_framework by CJSCommonPlatform.
the class CakeShopPostgresIT method before.
@Before
public void before() throws Exception {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
// Increase max total connection to 200
cm.setMaxTotal(200);
// Increase default max connection per route to 20
cm.setDefaultMaxPerRoute(20);
ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
client = new ResteasyClientBuilder().httpEngine(engine).build();
}
Aggregations