@Configuration @EnableAsync @Slf4j public class AsyncConfiguration implements AsyncConfigurer { @Value("${thread.pool.size}") private int poolSize; @Override public Executor getAsyncExecutor() { return Executors.newFixedThreadPool(poolSize); } //Si on veut une gestion particulière pour les exceptions @Override public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { return ((ex, method, obj) -> { String errorMessage = "Async exception message " + ex.getMessage() + " method " + method.getName() + " " + Arrays.toString(obj); log.error(errorMessage, ex); specialTreatmentForAsynchExport(ex, method, errorMessage, obj); }); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter