From 08222d60d44faa5c67361038875e2b0cefe1b40a Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Sun, 26 May 2019 18:04:26 +0200 Subject: [PATCH] Separates host and URI, to facilitate connection reuse --- .../kafka/keyvalue/onupdate/hc/UpdatesDispatcherHttp.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/se/yolean/kafka/keyvalue/onupdate/hc/UpdatesDispatcherHttp.java b/src/main/java/se/yolean/kafka/keyvalue/onupdate/hc/UpdatesDispatcherHttp.java index 18f70ba..8d4fdc5 100644 --- a/src/main/java/se/yolean/kafka/keyvalue/onupdate/hc/UpdatesDispatcherHttp.java +++ b/src/main/java/se/yolean/kafka/keyvalue/onupdate/hc/UpdatesDispatcherHttp.java @@ -7,7 +7,6 @@ import org.apache.http.HttpHost; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; @@ -26,16 +25,12 @@ public class UpdatesDispatcherHttp implements UpdatesDispatcher { ResponseHandlerAck responseHandler = new ResponseHandlerAck(); UpdateTarget target; CloseableHttpClient client; - HttpClientContext context; public UpdatesDispatcherHttp(String configuredTarget) { target = new UpdateTarget(configuredTarget); HttpHost host = target.getHttpclientContextHost(); // If we want to manage contexts logger.info("Creating http client for host {} target {}", host, target); - context = HttpClientContext.create(); - context.setTargetHost(host); - BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(); client = HttpClients.createMinimal(connectionManager); } @@ -47,7 +42,7 @@ public void dispatch(String topicName, UpdatesBodyPerTopic body) throws TargetAc post.setEntity(getEntity(body)); ResponseResult result; try { - result = client.execute(post, responseHandler, context); + result = client.execute(target.getHttpclientContextHost(), post, responseHandler); } catch (ClientProtocolException e) { throw new TargetAckFailedException(e); } catch (IOException e) {