-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mockito for Spring
By :
Java 7 has a feature called Future. Futures let you retrieve the result of an asynchronous operation at a later time. The FutureTask class runs in a separate thread, which allows you to perform non-blocking asynchronous operations. Spring provides an @Async annotation to make it more easier to use. We'll explore Java's Future feature and Spring's @Async declarative approach:
Create a project, TimeTravellingWithSpring, and add a package, com.packt.async.
We'll exercise a bank's use case, where an automated job will run and settle loan accounts. It will also find all the defaulters who haven't paid the loan EMI for a month and then send an SMS to their number. The job takes time to process thousands of accounts, so it will be good if we can send SMSes asynchronously to minimize the burden of the job. We'll create a service class to represent the job, as shown in the following code snippet:
@Service
public class AccountJob {
@Autowired
private SMSTask smsTask...
Change the font size
Change margin width
Change background colour