Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

CHAPTER 15: Task Scheduling in Spring > Task Scheduling in the Sample Applicati...

Task Scheduling in the Sample Application

In the SpringBlog application, we will store the history records for both blog posting entries and comments for auditing purposes. However, we also decided to keep only those history records for 30 days in order not to consume too much database storage. To fulfill the requirement, we will adopt Spring 3’s TaskScheduler abstraction support to implement a schedule job to purge the audit records older than 30 days. The job will run every day at midnight.

We will use the annotation style for task scheduling. First we will define an interface for the housekeeping job. Listing 15-17 shows the interface.

Listing 15-17. The HousekeepingService Interface

package com.apress.prospring3.springblog.service;

public interface HousekeepingService {

    /**
    * Scheduled job to purge audit records.
    */
    public void auditPurgeJob();

}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial