mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 13:22:07 +08:00
1、新增tracefilter中的trace-id,服务日志mdc打印和请求响应增加trace-id;2、恢复access_api_log和access_error_log的清理定时任务;3、补充服务中的线程池使用TransmittableThreadLocal;
This commit is contained in:
+24
@@ -1,7 +1,12 @@
|
||||
package com.cf.imes.framework.async;
|
||||
|
||||
import com.alibaba.ttl.TtlRunnable;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* 异步任务 Configuration
|
||||
@@ -9,4 +14,23 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||
@AutoConfiguration
|
||||
@EnableAsync
|
||||
public class ChenfengAsyncAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public BeanPostProcessor threadPoolTaskExecutorBeanPostProcessor() {
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (!(bean instanceof ThreadPoolTaskExecutor)) {
|
||||
return bean;
|
||||
}
|
||||
// 修改提交的任务,接入 TransmittableThreadLocal
|
||||
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) bean;
|
||||
executor.setTaskDecorator(TtlRunnable::get);
|
||||
return executor;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -257,9 +257,9 @@ public class GlobalExceptionHandler {
|
||||
public CommonResult serviceExceptionHandler(ServiceException ex) {
|
||||
// 系统异常输出堆栈
|
||||
if(INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
|
||||
log.info("[serviceExceptionHandler]", ex);
|
||||
log.error("[serviceExceptionHandler]", ex);
|
||||
} else {
|
||||
log.info(String.format("==========[serviceExceptionHandler]==========,%s:%s", ex.getCode(), ex.getMessage()));
|
||||
log.error(String.format("==========[serviceExceptionHandler]==========,%s:%s", ex.getCode(), ex.getMessage()));
|
||||
}
|
||||
return CommonResult.error(ex.getCode(), ex.getMessage());
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class GlobalExceptionHandler {
|
||||
*/
|
||||
@ExceptionHandler(value = PayException.class)
|
||||
public CommonResult payExceptionHandler(PayException ex) {
|
||||
log.info(String.format("==========[payExceptionHandler]==========,%s", ex.getMessage()));
|
||||
log.error(String.format("==========[payExceptionHandler]==========,%s", ex));
|
||||
return CommonResult.error(ex.getCode(), ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user