I have a public interface, Synchronous, that gets exposed to several service layer classes. Its intent is to lookup an object graph based on the id being passed, do some business logic and then pass it on to the Spring Asynchronous method Asynchronous.doWork to finish the rest of the task.
I'm trying to use the Spring AsyncResult but I'm unsure what the returned object WorkResult actually gets returned to. Do I need to put a handler somewhere in the SynchronousImpl? Ideas?
Sync Public Service:
public class SynchronousImpl implements Synchronous {
private Asynchronous async;
//business logic
public void doWork(long id){
async.doWork(id);
}
}
Async Worker Class:
public class Asynchronous {
@Async
public Future<WorkResult> doWork(long id){
//business logic
WorkResult result = new WorkResult(id, "Finished");
return new AsyncResult<WorkResult>(result);
}
}