I have two Spring based async thread pools and methods in the same Spring bean. The doWork()
uses the default Spring thread pool and holdAndReprocess()
uses its own Spring thread pool.
I currently have my class setup like below where doWork
processes some work and then if a failure occurs it parks the thread in the holdAndReprocess()
"queue" thread pool and then waits and reprocesses the thread by calling the doWork()
. With my current setup, the call to holdAndReprocess()
and then the call back to doWork()
is synchronous. Any ideas on how to wire this such that all communication between the doWork()
and holdAndReprocess
is asynchronous?
I'm using xml backed configuration and not pure annotation driven Spring beans.
public class AsyncSampleImpl implements AsyncSample {
@Async
public void doWork(){
holdAndReprocess();
}
@Async("queue")
@Transactional(propagation = Propagation.REQUIRED)
public void holdAndReprocess(){
//sleeps thread for static amount of time and then reprocesses
doWork();
}
}