/** * Create a new instance of the {@code HttpComponentsAsyncClientHttpRequestFactory} * with a default {@link HttpAsyncClient} and {@link HttpClient}. */ public HttpComponentsAsyncClientHttpRequestFactory() { super(); this.asyncClient = HttpAsyncClients.createSystem(); }
public void close() throws Exception { httpClient.close(); }
private void setupAsyncClient() { final HttpAsyncClientBuilder clientBuilder = HttpAsyncClients.custom(); if (sslContext != null) { clientBuilder.setSSLContext(sslContext); clientBuilder.addInterceptorFirst(new HttpsResponseInterceptor()); } httpAsyncClient = clientBuilder.setDefaultCredentialsProvider(getCredentialsProvider()).build(); httpAsyncClient.start(); }
public SentinelApiClient() { IOReactorConfig ioConfig = IOReactorConfig.custom().setConnectTimeout(3000).setSoTimeout(10000) .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2).build(); httpClient = HttpAsyncClients.custom().setRedirectStrategy(new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(final String method) { return false; } }).setMaxConnTotal(4000).setMaxConnPerRoute(1000).setDefaultIOReactorConfig(ioConfig).build(); httpClient.start(); }
private CloseableHttpAsyncClient createAsyncHttpClient(NHttpClientConnectionManager connectionManager) { return configureHttpClient( HttpAsyncClients.custom() .setConnectionManager(connectionManager) .setDefaultRequestConfig(getRequestConfig()) .setProxyAuthenticationStrategy(httpClientConfig.getProxyAuthenticationStrategy()) .setRoutePlanner(getRoutePlanner()) .setDefaultCredentialsProvider(httpClientConfig.getCredentialsProvider()) ).build(); }
private HttpAsyncClient startAsyncClient() { HttpAsyncClient client = getAsyncClient(); if (client instanceof CloseableHttpAsyncClient) { CloseableHttpAsyncClient closeableAsyncClient = (CloseableHttpAsyncClient) client; if (!closeableAsyncClient.isRunning()) { closeableAsyncClient.start(); } } return client; }
@Override public void start() { delegate.start(); } }
@Override public void sendAsyncRequestImpl(HttpUriRequest request, Callback<HttpResponse> callback) throws IOException { this.client.execute(request, new FutureCallback<HttpResponse>() { @Override public void completed(HttpResponse result) { callback.onSuccess(result); } @Override public void failed(Exception ex) { callback.onFailure(ex); } @Override public void cancelled() { throw new UnsupportedOperationException(); } }); }
@Override public boolean isRunning() { return delegate.isRunning(); }
@Override public ApacheHttpAsyncClient createHttpClient(Config config, SharedResourcesBroker<GobblinScopeTypes> broker) { return new ApacheHttpAsyncClient(HttpAsyncClientBuilder.create(), config, broker); }
private HttpAsyncClient startAsyncClient() { HttpAsyncClient client = getAsyncClient(); if (client instanceof CloseableHttpAsyncClient) { CloseableHttpAsyncClient closeableAsyncClient = (CloseableHttpAsyncClient) client; if (!closeableAsyncClient.isRunning()) { closeableAsyncClient.start(); } } return client; }
@Autowired public AsyncNotifyService(ServerListService serverListService) { this.serverListService = serverListService; httpclient.start(); }
@Override public void close() throws IOException { client.close(); } }
protected <T extends JestResult> Future<HttpResponse> executeAsyncRequest(Action<T> clientRequest, JestResultHandler<? super T> resultHandler, HttpUriRequest request) { if (httpClientContextTemplate != null) { return asyncClient.execute(request, createContextInstance(), new DefaultCallback<T>(clientRequest, request, resultHandler)); } return asyncClient.execute(request, new DefaultCallback<T>(clientRequest, request, resultHandler)); }
/** * Create a new instance of the {@code HttpComponentsAsyncClientHttpRequestFactory} * with a default {@link HttpAsyncClient} and {@link HttpClient}. */ public HttpComponentsAsyncClientHttpRequestFactory() { super(); this.asyncClient = HttpAsyncClients.createSystem(); }
public <T extends JestResult> void executeAsync(final Action<T> clientRequest, final JestResultHandler<? super T> resultHandler, final RequestConfig requestConfig) { synchronized (this) { if (!asyncClient.isRunning()) { asyncClient.start(); } } HttpUriRequest request = prepareRequest(clientRequest, requestConfig); executeAsyncRequest(clientRequest, resultHandler, request); }
@Override public void close() throws IOException { delegate.close(); }
@Override protected void close(CloseableHttpAsyncClient client) throws IOException { client.close(); }