Scheduling asynchronous tasks with returning results
Using tasks means also being able to define when they should be executed. This recipe is all about this topic, and also about getting the returning results whenever they return.
Getting ready
Let's first add our Java EE 8 dependency:
<dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency>
How to do it...
- Let's first create a
User
POJO:
public class User { private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public User(Long id, String name) { this.id = id; this.name = name; } @Override...