Jun 18th, 2012, 03:18 AM
Intercepting async calls
Hi everyone !
Simple question : I'm using the @Async annotation and I'm wondering if there is an existing interceptor allowing to execute some in-house code :
- (1) just before the async thread is started (we're on the caller thread)
- (2) just after the async thread is started (we're on the called thread)
In (1) I'd like to be able to transmit caller stacktrace to called thread, via a special method parameter
In (2) I'd like to populate current thread local with latter special method parameter values
Jun 18th, 2012, 09:04 AM
From what I've read, AspectJ pointcuts can target specific annotations. I don't think there's any particular reason why you couldn't target @Async; if I were you I would give it a try. Of course with @Before and @AfterReturning you could pass all the parameters you need...for that, just take a look at the specific section in the Spring reference guide.