diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java index 5efda119..90f36547 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/DynamicThreadPool.java @@ -22,14 +22,11 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.context.annotation.Bean; - /** * Dynamic thread pool. */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) -@Bean public @interface DynamicThreadPool { } diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java new file mode 100644 index 00000000..4c482897 --- /dev/null +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/SpringDynamicThreadPool.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.hippo4j.core.executor; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.context.annotation.Bean; + +/** + *@author : wh + *@date : 2022/10/2 16:10 + *@description: + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Bean +public @interface SpringDynamicThreadPool { +} diff --git a/hippo4j-example/hippo4j-config-etcd-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/etcd/config/ThreadPoolConfig.java b/hippo4j-example/hippo4j-config-etcd-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/etcd/config/ThreadPoolConfig.java index 524620a3..3f3e33cc 100644 --- a/hippo4j-example/hippo4j-config-etcd-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/etcd/config/ThreadPoolConfig.java +++ b/hippo4j-example/hippo4j-config-etcd-spring-boot-starter-example/src/main/java/cn/hippo4j/example/config/etcd/config/ThreadPoolConfig.java @@ -17,12 +17,12 @@ package cn.hippo4j.example.config.etcd.config; -import cn.hippo4j.core.executor.DynamicThreadPool; +import java.util.concurrent.ThreadPoolExecutor; + +import cn.hippo4j.core.executor.SpringDynamicThreadPool; import cn.hippo4j.core.executor.support.ThreadPoolBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import java.util.concurrent.ThreadPoolExecutor; +import org.springframework.context.annotation.Configuration; /** * @author : wh @@ -32,7 +32,7 @@ import java.util.concurrent.ThreadPoolExecutor; @Configuration public class ThreadPoolConfig { - @DynamicThreadPool + @SpringDynamicThreadPool public ThreadPoolExecutor messageConsumeDynamicExecutor() { String threadPoolId = "message-consume"; ThreadPoolExecutor messageConsumeDynamicExecutor = ThreadPoolBuilder.builder() diff --git a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java index a99bac81..f59432ec 100644 --- a/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java +++ b/hippo4j-example/hippo4j-example-core/src/main/java/cn/hippo4j/example/core/config/DynamicThreadPoolConfig.java @@ -20,7 +20,7 @@ package cn.hippo4j.example.core.config; import java.util.concurrent.Executor; import java.util.concurrent.ThreadPoolExecutor; -import cn.hippo4j.core.executor.DynamicThreadPool; +import cn.hippo4j.core.executor.SpringDynamicThreadPool; import cn.hippo4j.core.executor.support.ThreadPoolBuilder; import cn.hippo4j.example.core.handler.TaskTraceBuilderHandler; import cn.hippo4j.example.core.inittest.TaskDecoratorTest; @@ -41,7 +41,7 @@ import static cn.hippo4j.example.core.constant.GlobalTestConstant.MESSAGE_PRODUC @Configuration public class DynamicThreadPoolConfig { - @DynamicThreadPool + @SpringDynamicThreadPool public Executor messageConsumeTtlDynamicThreadPool() { String threadPoolId = MESSAGE_CONSUME; ThreadPoolExecutor customExecutor = ThreadPoolBuilder.builder() @@ -58,7 +58,7 @@ public class DynamicThreadPoolConfig { return ttlExecutor; } - @DynamicThreadPool + @SpringDynamicThreadPool public ThreadPoolExecutor messageProduceDynamicThreadPool() { String threadPoolId = MESSAGE_PRODUCE; ThreadPoolExecutor produceExecutor = ThreadPoolBuilder.builder() @@ -82,7 +82,7 @@ public class DynamicThreadPoolConfig { * @return */ // @Bean - @DynamicThreadPool + @SpringDynamicThreadPool public ThreadPoolTaskExecutor testSpringThreadPoolTaskExecutor() { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setThreadNamePrefix("test-spring-task-executor_");