AsyncConfiguration.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5. package com.gct.tools.etlcamelhuge.camelconfig;
  6. import java.lang.reflect.Method;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
  10. import org.springframework.context.annotation.Bean;
  11. import org.springframework.context.annotation.Configuration;
  12. import org.springframework.core.task.AsyncTaskExecutor;
  13. import org.springframework.scheduling.annotation.AsyncConfigurer;
  14. import org.springframework.scheduling.annotation.EnableAsync;
  15. import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
  16. @Configuration
  17. @EnableAsync
  18. public class AsyncConfiguration implements AsyncConfigurer {
  19. public AsyncConfiguration() {
  20. }
  21. @Bean
  22. public AsyncTaskExecutor asyncTaskExecutor() {
  23. ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
  24. executor.setCorePoolSize(8);
  25. executor.setMaxPoolSize(8);
  26. return executor;
  27. }
  28. public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
  29. return new LogAsyncUncaughtExceptionHandler();
  30. }
  31. class LogAsyncUncaughtExceptionHandler implements AsyncUncaughtExceptionHandler {
  32. LogAsyncUncaughtExceptionHandler() {
  33. }
  34. public void handleUncaughtException(Throwable ex, Method method, Object... params) {
  35. String paramLog = "";
  36. int i = 0;
  37. for(Object param : params) {
  38. paramLog = paramLog + "param:" + i + "=>" + param.toString() + " ";
  39. }
  40. Logger log = LoggerFactory.getLogger(this.getClass());
  41. log.error("Method:{} run error,Exception Message:{},StackTrace:{},input params:{}", new Object[]{method.getName(), ex.getMessage(), ex.getStackTrace(), paramLog});
  42. }
  43. }
  44. }