10.3. The Batch Run Date

I mentioned previously that the application should have a date and time component that can be configured for testing. The batch components must have a date and time component that contains the current batch run date. The reason for this is that batch scheduling can often be delayed and cross the midnight boundary of the current day into the next day, especially when batch is executed in the evening.

To explain, there are usually batch jobs that use the current date (and possibly time) for processing purposes. Assume a job archives and purges records that are older than three days (including today). If the batch schedule executes on time, the job will delete all the correct records. However, if the schedule runs after midnight, it will archive and purge one day less (see Figure 10-7).

Figure 10.7. Figure 10-7

Figure 10-7 shows that if the job runs before midnight, it will archive and purge records older than Today-2, whereas if it runs after midnight, it will delete records older than Today-1. This could cause a variety of issues when the data isn't present during the online day.

It is therefore paramount that batch components have a common batch date/time component and do not rely on the system clock. The batch run date needs to be updated as part of the batch schedule — usually as one of the last jobs in the schedule to set the next batch run date based ...

Get Design – Build – Run: Applied Practices and Principles for Production-Ready Software Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.