Commit 05a5dea2 authored by Matija Obreza's avatar Matija Obreza

connectTimeout, readTimeout

parent 87fea8d2
......@@ -83,6 +83,12 @@ public class GenesysClient {
/** The api secret. */
private String apiSecret;
/** Socket connect timeout */
private int connectTimeout = 20;
/** Socket read timeout */
private int readTimeout = 120;
static {
objectMapper = new ObjectMapper();
......@@ -97,6 +103,22 @@ public class GenesysClient {
public GenesysClient() {
}
public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}
public int getReadTimeout() {
return readTimeout;
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
public int getConnectTimeout() {
return connectTimeout;
}
/**
* Sets the base url.
*
......@@ -246,8 +268,8 @@ public class GenesysClient {
service.signRequest(accessToken, request);
request.setConnectionKeepAlive(true);
request.setConnectTimeout(10, TimeUnit.SECONDS);
request.setReadTimeout(30, TimeUnit.SECONDS);
request.setConnectTimeout(this.connectTimeout, TimeUnit.SECONDS);
request.setReadTimeout(this.readTimeout, TimeUnit.SECONDS);
request.setCharset("UTF-8");
Response response = null;
......@@ -283,8 +305,8 @@ public class GenesysClient {
_log.error("HTTP response code: " + response.getCode());
_log.error("Response: " + responseBody);
if (responseBody.contains("Deadlock found when trying to get lock; try restarting transaction")
|| responseBody
.contains("nested exception is org.hibernate.exception.LockAcquisitionException: could not execute statement")) {
|| responseBody.contains("nested exception is org.hibernate.exception.LockAcquisitionException: could not execute statement")
|| responseBody.contains("nested exception is org.hibernate.exception.LockTimeoutException: could not execute statement")) {
throw new PleaseRetryException(responseBody);
} else
throw new GenesysApiException("Unexpected error: " + responseBody);
......
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 to comment