diff --git a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/package-info.java b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/package-info.java index 339ac7d1f..a1e88dd75 100644 --- a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/package-info.java +++ b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/package-info.java @@ -8,7 +8,7 @@ * 6. MQ:在 Producer 发送消息时,Header 带上 organ-id 组织编号;在 Consumer 消费消息时,将 Header 的 organ-id 组织编号,添加到组织上下文。 * 7. Async:异步需要保证 ThreadLocal 的传递性,通过使用阿里开源的 TransmittableThreadLocal 实现。相关的改造点,可见: * 1)Spring Async: - * {@link com.cf.imes.framework.quartz.config.ChenfengAsyncAutoConfiguration#threadPoolTaskExecutorBeanPostProcessor()} + * {@link com.cf.imes.framework.quartz.config.ChenfengAsyncThreadAutoConfiguration#threadPoolTaskExecutorBeanPostProcessor()} * 2)Spring Security: * TransmittableThreadLocalSecurityContextHolderStrategy * 和 chenfengSecurityAutoConfiguration#securityContextHolderMethodInvokingFactoryBean() 方法 diff --git a/cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncThreadAutoConfiguration.java similarity index 83% rename from cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncAutoConfiguration.java rename to cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncThreadAutoConfiguration.java index 261560ff3..cea6b48b8 100644 --- a/cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-job/src/main/java/com/cf/imes/framework/quartz/config/ChenfengAsyncThreadAutoConfiguration.java @@ -5,16 +5,13 @@ 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.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; /** - * 异步任务 Configuration + * 异步线程 Configuration */ @AutoConfiguration -@EnableAsync -public class ChenfengAsyncAutoConfiguration { +public class ChenfengAsyncThreadAutoConfiguration { @Bean public BeanPostProcessor threadPoolTaskExecutorBeanPostProcessor() { diff --git a/cf-framework/cf-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cf-framework/cf-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 3bd633b75..a49ba4750 100644 --- a/cf-framework/cf-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cf-framework/cf-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1,2 @@ com.cf.imes.framework.quartz.config.ChenfengXxlJobAutoConfiguration -com.cf.imes.framework.quartz.config.ChenfengAsyncAutoConfiguration +com.cf.imes.framework.quartz.config.ChenfengAsyncThreadAutoConfiguration diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/async/ChenfengAsyncAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/async/ChenfengAsyncAutoConfiguration.java new file mode 100644 index 000000000..607662af3 --- /dev/null +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/async/ChenfengAsyncAutoConfiguration.java @@ -0,0 +1,12 @@ +package com.cf.imes.framework.async; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * 异步任务 Configuration + */ +@AutoConfiguration +@EnableAsync +public class ChenfengAsyncAutoConfiguration { +} diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cf-framework/cf-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 63ac50694..b3c89f862 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cf-framework/cf-spring-boot-starter-web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -3,3 +3,4 @@ com.cf.imes.framework.jackson.config.ChenfengJacksonAutoConfiguration com.cf.imes.framework.swagger.config.ChenfengSwaggerAutoConfiguration com.cf.imes.framework.web.config.ChenfengWebAutoConfiguration com.cf.imes.framework.apilog.config.ChenfengApiLogRpcAutoConfiguration +com.cf.imes.framework.async.ChenfengAsyncAutoConfiguration diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/ExecutorServerApplication.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/ExecutorServerApplication.java index e1a54df6c..257bbaaed 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/ExecutorServerApplication.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/ExecutorServerApplication.java @@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; /** @@ -13,7 +12,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableAspectJAutoProxy(exposeProxy = true) // add config @EnableFeignClients -@EnableAsync @EnableScheduling //开启定时任务 public class ExecutorServerApplication { public static void main(String[] args) { diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/ThreadPoolConfig.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/ThreadPoolConfig.java index 6c511e92d..ae9e10916 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/ThreadPoolConfig.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/ThreadPoolConfig.java @@ -1,14 +1,11 @@ package com.cf.imes.module.executor.util; import lombok.extern.slf4j.Slf4j; -import org.slf4j.MDC; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.TaskDecorator; import org.springframework.scheduling.annotation.AsyncConfigurer; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.HashMap; @@ -16,15 +13,6 @@ import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.LinkedBlockingQueue; -import cn.hutool.core.thread.ThreadFactoryBuilder; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; - -import javax.annotation.Nonnull; /** @@ -32,7 +20,6 @@ import javax.annotation.Nonnull; * @author FengJinSong */ @Slf4j -@EnableAsync @Configuration public class ThreadPoolConfig implements AsyncConfigurer { diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/ManageServerApplication.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/ManageServerApplication.java index 0ef00d5f3..d6aec9b73 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/ManageServerApplication.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/ManageServerApplication.java @@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.scheduling.annotation.EnableAsync; /** * @author there @@ -12,7 +11,6 @@ import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication @EnableAspectJAutoProxy(exposeProxy = true) // add config @EnableFeignClients -@EnableAsync public class ManageServerApplication { public static void main(String[] args) { SpringApplication.run(ManageServerApplication.class, args);