From 566fa78ef05fb2f33bc2df1bcb0e56f3faff1663 Mon Sep 17 00:00:00 2001 From: ymlam Date: Sat, 23 Aug 2014 01:41:28 +0000 Subject: [PATCH] Added attribute sleepBetweenJobs, time in milliseconds, for the service threads to sleep between consecutive jobs (or more exact batches of jobs). --- src/altk/comm/engine/Broadcast.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/altk/comm/engine/Broadcast.java b/src/altk/comm/engine/Broadcast.java index bad8595..9aad074 100644 --- a/src/altk/comm/engine/Broadcast.java +++ b/src/altk/comm/engine/Broadcast.java @@ -32,7 +32,7 @@ public abstract class Broadcast { private static final int SCHEDULER_THREAD_POOL_SIZE = 5; private static final String ACTIVITY_RECORD_ID_PARAM_NAME_DEFAULT = "activity_record_id"; - + private static final long SLEEP_BETWEEN_JOBS_DEFAULT = 0; public final String broadcastType; private String broadcastId; @@ -55,6 +55,11 @@ public abstract class Broadcast protected String postBackURL; private PostBack postBack; public long expireTime; + + /** + * Sleep time in milliseconds between consecutive job processing (actualliy batch) + */ + protected long sleepBetweenJobs; protected static Logger myLogger = Logger.getLogger(Broadcast.class); @@ -342,6 +347,17 @@ public abstract class Broadcast terminate(BroadcastState.ABORTED, t + ": " + t.getMessage()); } } + if (sleepBetweenJobs > 0) + { + try + { + Thread.sleep(sleepBetweenJobs); + } + catch (InterruptedException e1) + { + // Do nothing? + } + } } } @@ -357,6 +373,7 @@ public abstract class Broadcast this.broadcastType = broadcastType; this.activityRecordIdParamName = activityRecordIdParamName == null? ACTIVITY_RECORD_ID_PARAM_NAME_DEFAULT : activityRecordIdParamName; this.jobReportRootNodeName = jobReportRootNodeName; + sleepBetweenJobs = SLEEP_BETWEEN_JOBS_DEFAULT; readyQueue = new LinkedBlockingQueue(); serviceThreadPool = new ArrayList(); recipientList = new ArrayList();