2011-11-23 17:46:16,277 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Start execution of async. task with return>
2011-11-23 17:46:16,277 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Start execution of async. task with return>
2011-11-23 17:46:16,277 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Start execution of async. task with return>
2011-11-23 17:46:21,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task with return>
2011-11-23 17:46:21,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task with return>
2011-11-23 17:46:21,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task with return>
Result1: Hello: Clarence
Result2: Hello: John
Result3: Hello: Robert
2011-11-23 17:46:26,277 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task>
2011-11-23 17:46:26,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task>
2011-11-23 17:46:26,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task>
2011-11-23 17:46:26,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task>
2011-11-23 17:46:26,278 INFO [com.apress.prospring3.ch15.service.async.AsyncServiceImpl]
­
<Complete execution of async. task>
From the output, you can see that all the calls were started at the same time. The three calling with
return values complete first and are displayed on the console output. Finally, the five asyncTask()
methods called were completed too.
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();
}
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home