public RocketChatEndpoint( @Value("${rocketchat.proxy.hostname:}") String proxyHostname, @Value("${rocketchat.proxy.port:80}") int proxyPort, @Value("${rocketchat.proxy.scheme:http}") String proxyScheme ) { httpClientBuilder = HttpClientBuilder.create() .setRetryHandler((exception, executionCount, context) -> executionCount < 3) .setConnectionBackoffStrategy(new ConnectionBackoffStrategy() { @Override public boolean shouldBackoff(Throwable t) { return t instanceof IOException; } @Override public boolean shouldBackoff(HttpResponse resp) { return false; } }) .setUserAgent("Smarti/0.0 Rocket.Chat-Endpoint/0.1"); if(StringUtils.isNotBlank(proxyHostname)) { httpClientBuilder.setProxy(new HttpHost(proxyHostname, proxyPort, proxyScheme)); } }
public BackoffStrategyExec( final ClientExecChain requestExecutor, final ConnectionBackoffStrategy connectionBackoffStrategy, final BackoffManager backoffManager) { super(); Args.notNull(requestExecutor, "HTTP client request executor"); Args.notNull(connectionBackoffStrategy, "Connection backoff strategy"); Args.notNull(backoffManager, "Backoff manager"); this.requestExecutor = requestExecutor; this.connectionBackoffStrategy = connectionBackoffStrategy; this.backoffManager = backoffManager; }
public ConnectionBackoffStrategy getConnectionBackoffStrategy() { return this.connectionBackoffStrategy; }
public void setConnectionBackoffStrategy(final ConnectionBackoffStrategy connectionBackoffStrategy) { this.connectionBackoffStrategy = connectionBackoffStrategy; }
public synchronized final ConnectionBackoffStrategy getConnectionBackoffStrategy() { return connectionBackoffStrategy; }
public synchronized void setConnectionBackoffStrategy(final ConnectionBackoffStrategy strategy) { connectionBackoffStrategy = strategy; }
/** * Assigns {@link ConnectionBackoffStrategy} instance. */ public final HttpClientBuilder setConnectionBackoffStrategy( final ConnectionBackoffStrategy connectionBackoffStrategy) { this.connectionBackoffStrategy = connectionBackoffStrategy; return this; }
@Test public void isABackoffStrategy() { assertTrue(impl instanceof ConnectionBackoffStrategy); }