Browse Source

Sleep between postback IO exceptions

tags/1.0.17
ymlam 3 years ago
parent
commit
2555d5e4e0
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      src/main/java/altk/comm/engine/Postback.java

+ 16
- 2
src/main/java/altk/comm/engine/Postback.java View File

@@ -59,12 +59,13 @@ import altk.comm.engine.Broadcast.PostbackThreadActionOnEmpty;
*/ */
public class Postback public class Postback
{ {
private static final String XML_VERSION_1_0_ENCODING_UTF_8 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
private static final String XML_VERSION_1_0_ENCODING_UTF_8 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
private static final int QUEUE_WAIT = 300; // seconds private static final int QUEUE_WAIT = 300; // seconds
private static final int POSTBACK_SERVER_WAIT_TIME = 10; // seconds private static final int POSTBACK_SERVER_WAIT_TIME = 10; // seconds


private static final int RETRIES_DEFAULT = 3;
private static final int RETRIES_DEFAULT = 5;
private static final int RETRY_SLEEP_SECONDS = 5;
private final String postBackURL; private final String postBackURL;
private final String xmlTopElement; private final String xmlTopElement;
@@ -134,6 +135,8 @@ public class Postback
switch (post(reportList)) switch (post(reportList))
{ {
case IRRECOVERABLE_ERROR: case IRRECOVERABLE_ERROR:
// YML: should abort broadcfast to contain damage.
break;
case SUCCESS: case SUCCESS:
break; break;
@@ -349,6 +352,17 @@ public class Postback
HttpContext context) HttpContext context)
{ {
if (executionCount >= maxRetries) return false; if (executionCount >= maxRetries) return false;
if (executionCount > 1)
{
try
{
Thread.sleep(RETRY_SLEEP_SECONDS * 1000);
}
catch (InterruptedException ex)
{
// ignore
}
}
return true; return true;
} }
}; };


Loading…
Cancel
Save