Commit ea1a3f21 by Amir Aharon

add params to init http client

parent a1e71715
...@@ -49,6 +49,7 @@ import java.util.Locale; ...@@ -49,6 +49,7 @@ import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.concurrent.TimeUnit;
import static common.microservice.io.iface.IRestClient.COMMAND_ERROR; import static common.microservice.io.iface.IRestClient.COMMAND_ERROR;
...@@ -58,7 +59,8 @@ import static common.microservice.io.iface.IRestClient.COMMAND_ERROR; ...@@ -58,7 +59,8 @@ import static common.microservice.io.iface.IRestClient.COMMAND_ERROR;
*/ */
public class RestHttpClient extends SimpleRestClient implements Closeable { public class RestHttpClient extends SimpleRestClient implements Closeable {
private final int HTTP_SOCKET_READ_TIMEOUT = Integer.valueOf(System.getProperty("microservice.http.client.read.timeout.seconds","30"));
private final int HTTP_SOCKET_CONNECT_TIMEOUT = Integer.valueOf(System.getProperty("microservice.http.client.connect.timeout.seconds","10"));
List<String> brrFieldNames = null; List<String> brrFieldNames = null;
// CloseableHttpAsyncClient httpAsyncClient = null; // CloseableHttpAsyncClient httpAsyncClient = null;
...@@ -85,7 +87,12 @@ public class RestHttpClient extends SimpleRestClient implements Closeable { ...@@ -85,7 +87,12 @@ public class RestHttpClient extends SimpleRestClient implements Closeable {
} }
private void initClient() { private void initClient() {
client = new OkHttpClient(); client = new OkHttpClient.Builder()
.connectTimeout(HTTP_SOCKET_CONNECT_TIMEOUT, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(HTTP_SOCKET_READ_TIMEOUT, TimeUnit.SECONDS)
.build();
// httpAsyncClient = createHttpClient(); // httpAsyncClient = createHttpClient();
// httpAsyncClient.start(); // httpAsyncClient.start();
initBaseRestValidation(); initBaseRestValidation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment