36 lines
1020 B
Java
36 lines
1020 B
Java
package com.imyeyu.api.config;
|
|
|
|
import jakarta.validation.constraints.NotNull;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
|
import java.util.Arrays;
|
|
|
|
/**
|
|
* 异步线程池配置
|
|
*
|
|
* @author 夜雨
|
|
* @since 2023-08-21 16:22
|
|
*/
|
|
@Slf4j
|
|
@EnableAsync
|
|
@Configuration
|
|
public class AsyncConfig implements AsyncConfigurer {
|
|
|
|
@Override
|
|
public @NotNull AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
|
return (e, method, obj) -> {
|
|
log.info("Exception message - {}", e.getMessage());
|
|
log.info("Method name - {}", method.getName());
|
|
log.info("Parameter values - {}", Arrays.toString(obj));
|
|
if (e instanceof Exception exception) {
|
|
log.info("exception: {}", exception.getMessage());
|
|
}
|
|
log.error("async uncaught error", e);
|
|
};
|
|
}
|
|
}
|