Fix SpringDynamicThreadPool does not take effect

pull/764/head
chen.ma 2 years ago
parent 508e894758
commit 76f1651f58

@ -17,6 +17,7 @@
package cn.hippo4j.core.executor; package cn.hippo4j.core.executor;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@ -25,8 +26,8 @@ import java.lang.annotation.Target;
/** /**
* Dynamic thread pool. * Dynamic thread pool.
*/ */
@Target(ElementType.METHOD) @Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DynamicThreadPool { public @interface DynamicThreadPool {
} }

@ -17,20 +17,24 @@
package cn.hippo4j.core.executor; package cn.hippo4j.core.executor;
import org.springframework.context.annotation.Bean;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.context.annotation.Bean;
/** /**
*@author : wh * A convenience annotation that is itself annotated with
*@date : 2022/10/2 16:10 * {@link Bean @Bean} and {@link DynamicThreadPool @DynamicThreadPool}.
*@description: *
* @since 1.4.2
*/ */
@Target(ElementType.METHOD) @Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented
@Bean @Bean
@DynamicThreadPool
public @interface SpringDynamicThreadPool { public @interface SpringDynamicThreadPool {
} }

@ -18,6 +18,7 @@
package cn.hippo4j.example.core.config; package cn.hippo4j.example.core.config;
import cn.hippo4j.core.executor.DynamicThreadPool; import cn.hippo4j.core.executor.DynamicThreadPool;
import cn.hippo4j.core.executor.SpringDynamicThreadPool;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder; import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.example.core.handler.TaskTraceBuilderHandler; import cn.hippo4j.example.core.handler.TaskTraceBuilderHandler;
import cn.hippo4j.example.core.inittest.TaskDecoratorTest; import cn.hippo4j.example.core.inittest.TaskDecoratorTest;
@ -59,8 +60,10 @@ public class DynamicThreadPoolConfig {
return ttlExecutor; return ttlExecutor;
} }
@Bean /**
@DynamicThreadPool * {@link Bean @Bean} and {@link DynamicThreadPool @DynamicThreadPool}.
*/
@SpringDynamicThreadPool
public ThreadPoolExecutor messageProduceDynamicThreadPool() { public ThreadPoolExecutor messageProduceDynamicThreadPool() {
return ThreadPoolBuilder.builderDynamicPoolById(MESSAGE_PRODUCE); return ThreadPoolBuilder.builderDynamicPoolById(MESSAGE_PRODUCE);
} }

Loading…
Cancel
Save