Most batch programs I know of execute when the "online" is off (i.e. midnight) and must be stopped before the online begins executing: a "Batch Window".
Still I can't seem to find the BatchWindow concept in the Spring Batch architecture.
So for our little project we created a BatchWindow hierarchy Strategy for handling this. This is our approach, and the idea is to kick-start a brainstorming session to see how the BatchWindow concept could fit in Spring-Batch.
(All code is pseudocode).
Particularly we have a CronBatchWindow impl.Code:interface BatchWindow{ //is in window right now boolean inWindow(); //is the following date inside the window boolean inWindow(Date); //when the window will be finished, based on the //current time. Date nextFinishTime(); }
Now we can Identify if we are inside a batch window or not. Notice that we require two cron expressions to define a batch window (We are not allowing to create cron expressions with "-" inside them)Code:class CronBatchWindow{ String startCronExpression; String stopCronExpression; }
Next we have a CompletionPolicy based on batch windows, called WindowBasedStepCompletionPolicy:
Code:class WindowBasedStepCompletionPolicy{ BatchWindow window = null; //remember, just the important stuff here public boolean isComplete(...){ boolean inWindow = this.window.inWindow(); ... } }
Regards
AB


Reply With Quote