How can I log this using Spring Async framework without having to put try catch around every async method? It doesnt seem to pass to the DefaultUncaughtExceptionHandler like normal.Code:@Async public void asyncExceptionTest() { int i=1/0; }
How can I log this using Spring Async framework without having to put try catch around every async method? It doesnt seem to pass to the DefaultUncaughtExceptionHandler like normal.Code:@Async public void asyncExceptionTest() { int i=1/0; }
Hello
Consider use AOP (around advice)
Let me know your advance
- Manuel Jordan
Kill Your Pride, Share Your Knowledge With All
The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7
Blog
Technical Reviewer of Apress
- Pro SpringSource dm Server
- Spring Enterprise Recipes: A Problem-Solution Approach
- Spring Recipes: A Problem-Solution Approach, 2nd Edition
- Pro Spring Integration
- Pro Spring Batch
- Pro Spring 3
- Pro Spring MVC: With Web Flow
- Pro Spring Security
Thanks for your reply...AOP seems like a solution but I think it would be better if you could directly specify the error handler. Would be more elegant IMO.
AOP offer a special type of advice. After advice, it is executed if an exception was thrown or not, even
you can work with specific types of exceptions like parameters, read documentation for more details.
To be honest I think AOP is the best option
- Manuel Jordan
Kill Your Pride, Share Your Knowledge With All
The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7
Blog
Technical Reviewer of Apress
- Pro SpringSource dm Server
- Spring Enterprise Recipes: A Problem-Solution Approach
- Spring Recipes: A Problem-Solution Approach, 2nd Edition
- Pro Spring Integration
- Pro Spring Batch
- Pro Spring 3
- Pro Spring MVC: With Web Flow
- Pro Spring Security
Thanks for your response but I think using AOP is a bit heavyweight and it would be much clearer, transparent and explicit if you could define your own ErrorHandler. There is something available for the @Scheduled to allow you to specify the error handler not sure why not for the @Async?