I am trying to run a long-term task (without blocking the execution pool of the HTTP request) using asynchronous tasks in the game. Jobs on Play is fully managed by the infrastructure, so Play will monitor database connections and transactions. This means that the task runs as a simple call within a single transaction. This works great for most use cases, but what if you need to commit some data before completing a job?
Well, according to Guillaume Bort , one option would be
to divide the process into several small tasks
He gives the following example:
@On("0 0 12 * * ?")
public class UpdateCounters extends Job {
public void doJob() {
List<Employee> empList = Employee.find("long and boring SQL :)").fetch();
for(Employee emp : empList) {
new UpdateEmployeeJob(emp).now().get();
}
}
}
... , , , . !
, ? , , , ?
, Promise (jobPromise), ( Job)...
, , ?