From 9bdb8102ea7867deb732a3ac1f5a406420e3c124 Mon Sep 17 00:00:00 2001 From: Han Lau Date: Mon, 30 Sep 2024 17:26:46 +0800 Subject: [PATCH] feat: support springboot3 (#1570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: support springboot3 * fix:add interface InitializingBean --- .../config-nacos-spring-boot3/README.md | 4 + .../config/config-nacos-spring-boot3/pom.xml | 97 ++++++++++++ ...nfigNacosSpringBootExampleApplication.java | 34 +++++ .../src/main/resources/application.properties | 66 +++++++++ .../main/resources/nacos-config.properties | 52 +++++++ examples/threadpool-example/config/pom.xml | 2 + .../adapter-dubbo-spring-boot3/README.md | 5 + .../pom.xml | 118 +++++++++++++++ .../consumer/ConsumerApplication.java | 35 +++++ .../consumer/DubboThreadTestService.java | 37 +++++ .../src/main/resources/application.properties | 23 +++ .../pom.xml | 40 +++++ .../dubbo/springboot3/DemoService.java | 29 ++++ .../pom.xml | 140 ++++++++++++++++++ .../dubbo/springboot3/DemoServiceImpl.java | 48 ++++++ .../springboot3/ProviderApplication.java | 37 +++++ .../src/main/resources/application.properties | 23 +++ .../server/adapter-dubbo-spring-boot3/pom.xml | 41 +++++ .../adapter-rabbitmq-spring-boot3/README.md | 5 + .../adapter-rabbitmq-spring-boot3/pom.xml | 63 ++++++++ ...rverAdapterRabbitMQExampleApplication.java | 34 +++++ .../config/RabbitMQTemplateConfig.java | 44 ++++++ .../config/RabbitMQThreadPoolConfig.java | 65 ++++++++ .../example/constants/SimpleMQConstant.java | 26 ++++ .../example/consumer/MessageConsumer.java | 46 ++++++ .../example/producer/MessageProduce.java | 54 +++++++ .../src/main/resources/application.properties | 17 +++ .../README.md | 5 + .../pom.xml | 83 +++++++++++ .../rabbitmq/example/MessageProduce.java | 71 +++++++++ ...rSpringCloudStreamRabbitMQApplication.java | 55 +++++++ .../src/main/resources/application.properties | 29 ++++ .../server/server-spring-boot3/README.md | 4 + .../server/server-spring-boot3/pom.xml | 107 +++++++++++++ .../server/ServerExampleApplication.java | 34 +++++ ...tor.support.CustomRejectedExecutionHandler | 1 + .../src/main/resources/application.properties | 26 ++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../adapter/web/WebAdapterConfiguration.java | 69 +++++++++ .../WebThreadPoolHandlerConfiguration.java | 87 +++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...bstractConfigThreadPoolDynamicRefresh.java | 11 +- ...ot.autoconfigure.AutoConfiguration.imports | 4 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + starters/threadpool/server/pom.xml | 5 + ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../adapter/dubbo/DubboThreadPoolAdapter.java | 6 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 + 58 files changed, 1787 insertions(+), 10 deletions(-) create mode 100644 examples/threadpool-example/config/config-nacos-spring-boot3/README.md create mode 100644 examples/threadpool-example/config/config-nacos-spring-boot3/pom.xml create mode 100644 examples/threadpool-example/config/config-nacos-spring-boot3/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosSpringBootExampleApplication.java create mode 100644 examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/application.properties create mode 100644 examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/nacos-config.properties create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/README.md create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/pom.xml create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/ConsumerApplication.java create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/DubboThreadTestService.java create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/resources/application.properties create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/pom.xml create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoService.java create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/pom.xml create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoServiceImpl.java create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/ProviderApplication.java create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/resources/application.properties create mode 100644 examples/threadpool-example/server/adapter-dubbo-spring-boot3/pom.xml create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/README.md create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/pom.xml create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/ServerAdapterRabbitMQExampleApplication.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQTemplateConfig.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQThreadPoolConfig.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/constants/SimpleMQConstant.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/consumer/MessageConsumer.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/producer/MessageProduce.java create mode 100644 examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/resources/application.properties create mode 100644 examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/README.md create mode 100644 examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/pom.xml create mode 100644 examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java create mode 100644 examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java create mode 100644 examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/resources/application.properties create mode 100644 examples/threadpool-example/server/server-spring-boot3/README.md create mode 100644 examples/threadpool-example/server/server-spring-boot3/pom.xml create mode 100644 examples/threadpool-example/server/server-spring-boot3/src/main/java/cn/hippo4j/example/server/ServerExampleApplication.java create mode 100644 examples/threadpool-example/server/server-spring-boot3/src/main/resources/META-INF/services/cn.hippo4j.common.executor.support.CustomRejectedExecutionHandler create mode 100644 examples/threadpool-example/server/server-spring-boot3/src/main/resources/application.properties create mode 100644 starters/threadpool/adapter/alibaba-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/dubbox/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/hystrix/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/kafka/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/stream-rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/stream-rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebAdapterConfiguration.java create mode 100644 starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebThreadPoolHandlerConfiguration.java create mode 100644 starters/threadpool/adapter/web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 starters/threadpool/server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 threadpool/core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/examples/threadpool-example/config/config-nacos-spring-boot3/README.md b/examples/threadpool-example/config/config-nacos-spring-boot3/README.md new file mode 100644 index 00000000..30067dd5 --- /dev/null +++ b/examples/threadpool-example/config/config-nacos-spring-boot3/README.md @@ -0,0 +1,4 @@ +启动项添加JVM配置参数: +``` +--add-opens java.base/java.util.concurrent=ALL-UNNAMED +``` \ No newline at end of file diff --git a/examples/threadpool-example/config/config-nacos-spring-boot3/pom.xml b/examples/threadpool-example/config/config-nacos-spring-boot3/pom.xml new file mode 100644 index 00000000..f4293e76 --- /dev/null +++ b/examples/threadpool-example/config/config-nacos-spring-boot3/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + cn.hippo4j + hippo4j-threadpool-config-nacos-spring-boot3 + ${revision} + + 2.0.0-SNAPSHOT + true + 3.3.3 + 2.4.1 + 1.17 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + + com.alibaba.boot + nacos-config-spring-boot-starter + 0.3.0-RC + + + org.springframework.boot + spring-boot-starter + + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + org.springframework.boot + spring-boot-starter-jetty + + + + org.springframework.boot + spring-boot-starter-test + test + + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + + cn.hippo4j + hippo4j-threadpool-config-spring-boot-starter + ${revision} + + + + org.springframework.boot + spring-boot-starter-actuator + + + + io.micrometer + micrometer-registry-prometheus + 1.13.3 + + + + + diff --git a/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosSpringBootExampleApplication.java b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosSpringBootExampleApplication.java new file mode 100644 index 00000000..c14f8551 --- /dev/null +++ b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/java/cn/hippo4j/example/config/nacos/ConfigNacosSpringBootExampleApplication.java @@ -0,0 +1,34 @@ +/* + * 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.example.config.nacos; + +import cn.hippo4j.core.enable.EnableDynamicThreadPool; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Config nacos spring boot 3.x example application + */ +@EnableDynamicThreadPool +@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.core") +public class ConfigNacosSpringBootExampleApplication { + + public static void main(String[] args) { + SpringApplication.run(ConfigNacosSpringBootExampleApplication.class, args); + } +} diff --git a/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/application.properties b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/application.properties new file mode 100644 index 00000000..166c04b3 --- /dev/null +++ b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/application.properties @@ -0,0 +1,66 @@ +#debug=true +server.port=8089 +server.servlet.context-path=/example + +management.security.enabled=false +management.context-path=/actuator + +spring.profiles.active=dev +spring.application.name=hippo4j-config-nacos-spring-boot3-starter-example + +## nacos spring-boot +nacos.config.server-addr=127.0.0.1:8848 +nacos.config.ext-config[0].data-id=hippo4j-nacos.yaml +nacos.config.ext-config[0].group=DEFAULT_GROUP +nacos.config.ext-config[0].auto-refresh=true + +spring.dynamic.thread-pool.enable=true +spring.dynamic.thread-pool.banner=true +spring.dynamic.thread-pool.check-state-interval=5 +spring.dynamic.thread-pool.monitor.enable=true +spring.dynamic.thread-pool.monitor.collect-types=micrometer +spring.dynamic.thread-pool.monitor.thread-pool-types=dynamic,web +spring.dynamic.thread-pool.monitor.initial-delay=10000 +spring.dynamic.thread-pool.monitor.collect-interval=5000 + +spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT +spring.dynamic.thread-pool.notify-platforms[0].token=ac0426a5-c712-474c-9bff-72b8b8f5caff +spring.dynamic.thread-pool.notify-platforms[1].platform=DING +spring.dynamic.thread-pool.notify-platforms[1].token=56417ebba6a27ca352f0de77a2ae9da66d01f39610b5ee8a6033c60ef9071c55 +spring.dynamic.thread-pool.notify-platforms[2].platform=LARK +spring.dynamic.thread-pool.notify-platforms[2].token=2cbf2808-3839-4c26-a04d-fd201dd51f9e + +spring.dynamic.thread-pool.nacos.data-id=hippo4j-nacos.yaml +spring.dynamic.thread-pool.nacos.group=DEFAULT_GROUP +spring.dynamic.thread-pool.config-file-type=yaml + +spring.dynamic.thread-pool.executors[0].thread-pool-id=message-consume +spring.dynamic.thread-pool.executors[0].thread-name-prefix=message-consume +spring.dynamic.thread-pool.executors[0].core-pool-size=2 +spring.dynamic.thread-pool.executors[0].maximum-pool-size=4 +spring.dynamic.thread-pool.executors[0].queue-capacity=1024 +spring.dynamic.thread-pool.executors[0].blocking-queue=ResizableCapacityLinkedBlockingQueue +spring.dynamic.thread-pool.executors[0].execute-time-out=800 +spring.dynamic.thread-pool.executors[0].rejected-handler=AbortPolicy +spring.dynamic.thread-pool.executors[0].keep-alive-time=6691 +spring.dynamic.thread-pool.executors[0].allow-core-thread-time-out=true +spring.dynamic.thread-pool.executors[0].alarm=true +spring.dynamic.thread-pool.executors[0].active-alarm=80 +spring.dynamic.thread-pool.executors[0].capacity-alarm=80 +spring.dynamic.thread-pool.executors[0].notify.interval=8 +spring.dynamic.thread-pool.executors[0].notify.receives=chen.ma +spring.dynamic.thread-pool.executors[1].thread-pool-id=message-produce +spring.dynamic.thread-pool.executors[1].thread-name-prefix=message-produce +spring.dynamic.thread-pool.executors[1].core-pool-size=2 +spring.dynamic.thread-pool.executors[1].maximum-pool-size=4 +spring.dynamic.thread-pool.executors[1].queue-capacity=1024 +spring.dynamic.thread-pool.executors[1].blocking-queue=ResizableCapacityLinkedBlockingQueue +spring.dynamic.thread-pool.executors[1].execute-time-out=800 +spring.dynamic.thread-pool.executors[1].rejected-handler=AbortPolicy +spring.dynamic.thread-pool.executors[1].keep-alive-time=6691 +spring.dynamic.thread-pool.executors[1].allow-core-thread-time-out=true +spring.dynamic.thread-pool.executors[1].alarm=true +spring.dynamic.thread-pool.executors[1].active-alarm=80 +spring.dynamic.thread-pool.executors[1].capacity-alarm=80 +spring.dynamic.thread-pool.executors[1].notify.interval=8 +spring.dynamic.thread-pool.executors[1].notify.receives=chen.ma diff --git a/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/nacos-config.properties b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/nacos-config.properties new file mode 100644 index 00000000..77e3f5e0 --- /dev/null +++ b/examples/threadpool-example/config/config-nacos-spring-boot3/src/main/resources/nacos-config.properties @@ -0,0 +1,52 @@ +# \u4EE5\u4E0B\u5185\u5BB9\u590D\u5236\u5230 nacos \u914D\u7F6E\u6587\u4EF6\u4E2D +# Copy the following to the nacos configuration file + +spring.dynamic.thread-pool.web.core-pool-size=64 +spring.dynamic.thread-pool.web.maximum-pool-size=128 +spring.dynamic.thread-pool.web.keep-alive-time=1000 +spring.dynamic.thread-pool.web.enable=true +spring.dynamic.thread-pool.default-executor.core-pool-size=1 +spring.dynamic.thread-pool.default-executor.maximum-pool-size=2 +spring.dynamic.thread-pool.default-executor.blocking-queue=ResizableCapacityLinkedBlockingQueue +spring.dynamic.thread-pool.default-executor.execute-time-out=100 +spring.dynamic.thread-pool.default-executor.keep-alive-time=6691 +spring.dynamic.thread-pool.default-executor.queue-capacity=1 +spring.dynamic.thread-pool.default-executor.rejected-handler=AbortPolicy +spring.dynamic.thread-pool.default-executor.active-alarm=90 +spring.dynamic.thread-pool.default-executor.capacity-alarm=85 +spring.dynamic.thread-pool.default-executor.alarm=true +spring.dynamic.thread-pool.default-executor.allow-core-thread-time-out=true +spring.dynamic.thread-pool.default-executor.notify.interval=5 +spring.dynamic.thread-pool.default-executor.notify.receives=chen.ma +spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT +spring.dynamic.thread-pool.notify-platforms[0].secret-key=ec3be378-6c99-45d2-a147-b400c7e94a08 +spring.dynamic.thread-pool.executors[0].thread-pool-id=message-consume +spring.dynamic.thread-pool.executors[0].thread-name-prefix=message-consume +spring.dynamic.thread-pool.executors[0].core-pool-size=2 +spring.dynamic.thread-pool.executors[0].maximum-pool-size=4 +spring.dynamic.thread-pool.executors[0].queue-capacity=1024 +spring.dynamic.thread-pool.executors[0].blocking-queue=ResizableCapacityLinkedBlockingQueue +spring.dynamic.thread-pool.executors[0].execute-time-out=800 +spring.dynamic.thread-pool.executors[0].rejected-handler=AbortPolicy +spring.dynamic.thread-pool.executors[0].keep-alive-time=6691 +spring.dynamic.thread-pool.executors[0].allow-core-thread-time-out=true +spring.dynamic.thread-pool.executors[0].alarm=true +spring.dynamic.thread-pool.executors[0].active-alarm=80 +spring.dynamic.thread-pool.executors[0].capacity-alarm=80 +spring.dynamic.thread-pool.executors[0].notify.interval=8 +spring.dynamic.thread-pool.executors[0].notify.receives=chen.ma +spring.dynamic.thread-pool.executors[1].thread-pool-id=message-produce +spring.dynamic.thread-pool.executors[1].thread-name-prefix=message-produce +spring.dynamic.thread-pool.executors[1].core-pool-size=2 +spring.dynamic.thread-pool.executors[1].maximum-pool-size=4 +spring.dynamic.thread-pool.executors[1].queue-capacity=1024 +spring.dynamic.thread-pool.executors[1].blocking-queue=ResizableCapacityLinkedBlockingQueue +spring.dynamic.thread-pool.executors[1].execute-time-out=800 +spring.dynamic.thread-pool.executors[1].rejected-handler=AbortPolicy +spring.dynamic.thread-pool.executors[1].keep-alive-time=6691 +spring.dynamic.thread-pool.executors[1].allow-core-thread-time-out=true +spring.dynamic.thread-pool.executors[1].alarm=true +spring.dynamic.thread-pool.executors[1].active-alarm=80 +spring.dynamic.thread-pool.executors[1].capacity-alarm=80 +spring.dynamic.thread-pool.executors[1].notify.interval=8 +spring.dynamic.thread-pool.executors[1].notify.receives=chen.ma diff --git a/examples/threadpool-example/config/pom.xml b/examples/threadpool-example/config/pom.xml index c6255187..62ed878f 100644 --- a/examples/threadpool-example/config/pom.xml +++ b/examples/threadpool-example/config/pom.xml @@ -23,5 +23,7 @@ config-etcd config-nacos-spring-boot-1x config-apollo-spring-boot-1x + + \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/README.md b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/README.md new file mode 100644 index 00000000..5a267d79 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/README.md @@ -0,0 +1,5 @@ +## spring-boot3 仅支持jdk17以上版本 +## 启动项添加JVM配置参数: +``` +--add-opens java.base/java.util.concurrent=ALL-UNNAMED +``` \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/pom.xml b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/pom.xml new file mode 100644 index 00000000..7203785e --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/pom.xml @@ -0,0 +1,118 @@ + + + + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-example + ${revision} + + 4.0.0 + + hippo4j-threadpool-adapter-dubbo-spring-boot3-consumer-example + + + + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-interface-example + ${project.version} + + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter + ${revision} + + + + io.micrometer + micrometer-registry-prometheus + + + + org.springframework.boot + spring-boot-starter-actuator + + + + cn.hippo4j + hippo4j-spring-boot-starter-monitor-micrometer + ${revision} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.tomcat.embed + tomcat-embed-core + + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + org.apache.zookeeper + zookeeper + ${zookeeper_version} + + + io.netty + netty-handler + + + io.netty + netty-transport-native-epoll + + + + + org.apache.curator + curator-framework + ${curator.version} + + + org.apache.curator + curator-client + ${curator.version} + + + org.apache.curator + curator-recipes + ${curator.version} + + + org.apache.curator + curator-x-discovery + ${curator.version} + + + + + diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/ConsumerApplication.java b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/ConsumerApplication.java new file mode 100644 index 00000000..a17925d6 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/ConsumerApplication.java @@ -0,0 +1,35 @@ +/* + * 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.example.server.adapter.dubbo.springboot3.consumer; + +import cn.hippo4j.core.enable.EnableDynamicThreadPool; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.stereotype.Service; + +@EnableDynamicThreadPool +@SpringBootApplication(scanBasePackages = {"cn.hippo4j.example.core", "cn.hippo4j.example.server"}) +@EnableDubbo +public class ConsumerApplication { + + public static void main(String[] args) { + SpringApplication.run(ConsumerApplication.class, args); + } + +} diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/DubboThreadTestService.java b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/DubboThreadTestService.java new file mode 100644 index 00000000..0d2e82fc --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/consumer/DubboThreadTestService.java @@ -0,0 +1,37 @@ +package cn.hippo4j.example.server.adapter.dubbo.springboot3.consumer; + +import cn.hippo4j.example.server.adapter.dubbo.springboot3.DemoService; +import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +@Slf4j +@Service +public class DubboThreadTestService { + + + @DubboReference(timeout = 2000, version = "1.0.0") + private DemoService demoService; + + @PostConstruct + public void init() { + ExecutorService executorService = Executors.newFixedThreadPool(10); + + ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + scheduledExecutorService.scheduleAtFixedRate(() -> + executorService.execute(() -> { + try { + String result = demoService.sayHello("world"); + log.info("返回信息:{}", result); + } catch (Exception e) { + log.error("dubbo接口抛出错误:", e); + } + }), 500, 500, TimeUnit.MILLISECONDS); + } +} diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/resources/application.properties b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/resources/application.properties new file mode 100644 index 00000000..03c3f2a8 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-consumer-example/src/main/resources/application.properties @@ -0,0 +1,23 @@ +server.port=8089 +debug=true + +spring.application.name=hippo4j-threadpool-adapter-dubbo-spring-boot3-consumer-example + +spring.dynamic.thread-pool.server-addr=http://localhost:6691 +### Use netty to report thread pool monitoring data. The default is http. +# spring.dynamic.thread-pool.report-type=netty +# spring.dynamic.thread-pool.netty-server-port=8899 +spring.dynamic.thread-pool.namespace=prescription +spring.dynamic.thread-pool.item-id=dynamic-threadpool-example +spring.dynamic.thread-pool.username=admin +spring.dynamic.thread-pool.password=123456 + +dubbo.application.name=${spring.application.name} +dubbo.protocol.name=dubbo +dubbo.protocol.port=20881 +# ??ip????????????????ip?localhost?127.0.x.x? +#dubbo.protocol.host=192.168.66.66 +dubbo.registry.id=zk-registry +dubbo.registry.address=zookeeper://127.0.0.1:2181 +dubbo.config-center.address=zookeeper://127.0.0.1:2181 +dubbo.metadata-report.address=zookeeper://127.0.0.1:2181 \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/pom.xml b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/pom.xml new file mode 100644 index 00000000..7ab6a8b0 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/pom.xml @@ -0,0 +1,40 @@ + + + + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-example + ${revision} + + 4.0.0 + + hippo4j-threadpool-adapter-dubbo-spring-boot3-interface-example + + + + ${project.name} + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + + + diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoService.java b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoService.java new file mode 100644 index 00000000..01dc5b2e --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-interface-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoService.java @@ -0,0 +1,29 @@ +/* + * 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.example.server.adapter.dubbo.springboot3; + +import java.util.concurrent.CompletableFuture; + +public interface DemoService { + + String sayHello(String name); + + default CompletableFuture sayHelloAsync(String name) { + return CompletableFuture.completedFuture(sayHello(name)); + } + +} diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/pom.xml b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/pom.xml new file mode 100644 index 00000000..870fbe5f --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/pom.xml @@ -0,0 +1,140 @@ + + + + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-example + ${revision} + + 4.0.0 + + hippo4j-threadpool-adapter-dubbo-spring-boot3-provider-example + + + + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-interface-example + ${project.version} + + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter + ${revision} + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter-adapter-dubbo + ${revision} + + + + + io.micrometer + micrometer-registry-prometheus + + + + org.springframework.boot + spring-boot-starter-actuator + + + + cn.hippo4j + hippo4j-spring-boot-starter-monitor-micrometer + ${revision} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.tomcat.embed + tomcat-embed-core + + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + org.apache.zookeeper + zookeeper + ${zookeeper_version} + + + io.netty + netty-handler + + + io.netty + netty-transport-native-epoll + + + + + org.apache.curator + curator-framework + ${curator.version} + + + org.apache.curator + curator-client + ${curator.version} + + + org.apache.curator + curator-recipes + ${curator.version} + + + org.apache.curator + curator-x-discovery + ${curator.version} + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoServiceImpl.java b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoServiceImpl.java new file mode 100644 index 00000000..6330cd87 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/DemoServiceImpl.java @@ -0,0 +1,48 @@ +/* + * 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.example.server.adapter.dubbo.springboot3; + + +import org.apache.dubbo.config.annotation.DubboService; +import org.apache.dubbo.config.annotation.Method; +import org.apache.dubbo.rpc.RpcContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.TimeUnit; + +@DubboService(interfaceClass = DemoService.class, version = "1.0.0", retries = 4, methods = { + @Method(name = "sayHello", retries = 6) +}) +public class DemoServiceImpl implements DemoService { + + private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class); + + @Override + public String sayHello(String name) { + logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return "Hello " + name; + + } + + +} diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/ProviderApplication.java b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/ProviderApplication.java new file mode 100644 index 00000000..727ec17e --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/java/cn/hippo4j/example/server/adapter/dubbo/springboot3/ProviderApplication.java @@ -0,0 +1,37 @@ +/* + * 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.example.server.adapter.dubbo.springboot3; + + +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import cn.hippo4j.core.enable.EnableDynamicThreadPool; + +import java.util.concurrent.CountDownLatch; + +@EnableDynamicThreadPool +@SpringBootApplication(scanBasePackages = {"cn.hippo4j.example.core", "cn.hippo4j.example.server"}) +@EnableDubbo(scanBasePackages = {"cn.hippo4j.example.server.adapter.dubbo.springboot3"}) +public class ProviderApplication { + public static void main(String[] args) throws Exception { + SpringApplication.run(ProviderApplication.class, args); + System.out.println("dubbo service started"); + new CountDownLatch(1).await(); + } +} diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/resources/application.properties b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/resources/application.properties new file mode 100644 index 00000000..26ed77c3 --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/adapter-dubbo-spring-boot-3x-provider-example/src/main/resources/application.properties @@ -0,0 +1,23 @@ +server.port=8088 +debug=true + +spring.application.name=hippo4j-threadpool-adapter-dubbo-spring-boot3-provider-example + +spring.dynamic.thread-pool.server-addr=http://localhost:6691 +### Use netty to report thread pool monitoring data. The default is http. +# spring.dynamic.thread-pool.report-type=netty +# spring.dynamic.thread-pool.netty-server-port=8899 +spring.dynamic.thread-pool.namespace=prescription +spring.dynamic.thread-pool.item-id=dynamic-threadpool-example +spring.dynamic.thread-pool.username=admin +spring.dynamic.thread-pool.password=123456 + +dubbo.application.name=${spring.application.name} +dubbo.protocol.name=dubbo +dubbo.protocol.port= -1 +# ??ip????????????????ip?localhost?127.0.x.x? +#dubbo.protocol.host=192.168.66.66 +dubbo.registry.id=zk-registry +dubbo.registry.address=zookeeper://127.0.0.1:2181 +dubbo.config-center.address=zookeeper://127.0.0.1:2181 +dubbo.metadata-report.address=zookeeper://127.0.0.1:2181 \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-dubbo-spring-boot3/pom.xml b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/pom.xml new file mode 100644 index 00000000..d8683d0c --- /dev/null +++ b/examples/threadpool-example/server/adapter-dubbo-spring-boot3/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + cn.hippo4j + hippo4j-threadpool-adapter-dubbo-spring-boot3-example + ${revision} + pom + + + adapter-dubbo-spring-boot3-consumer-example + adapter-dubbo-spring-boot3-provider-example + adapter-dubbo-spring-boot3-interface-example + + + + true + 2.0.0-SNAPSHOT + true + 3.3.3 + 3.2.15 + 3.8.1 + 5.1.0 + 1.17 + 17 + 17 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/README.md b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/README.md new file mode 100644 index 00000000..5a267d79 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/README.md @@ -0,0 +1,5 @@ +## spring-boot3 仅支持jdk17以上版本 +## 启动项添加JVM配置参数: +``` +--add-opens java.base/java.util.concurrent=ALL-UNNAMED +``` \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/pom.xml b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/pom.xml new file mode 100644 index 00000000..7afe3d37 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-threadpool-adapter-rabbitmq-spring-boot3-example + ${revision} + + true + 2.0.0-SNAPSHOT + 3.3.3 + 1.17 + 17 + 17 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter-adapter-rabbitmq + ${project.version} + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter + ${project.version} + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + org.springframework.boot + spring-boot-starter-amqp + + + diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/ServerAdapterRabbitMQExampleApplication.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/ServerAdapterRabbitMQExampleApplication.java new file mode 100644 index 00000000..821ccbdd --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/ServerAdapterRabbitMQExampleApplication.java @@ -0,0 +1,34 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example; + +import cn.hippo4j.core.enable.EnableDynamicThreadPool; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Server Adapter RabbitMQ Example Application + */ +@EnableDynamicThreadPool +@SpringBootApplication(scanBasePackages = {"cn.hippo4j.example.core", "cn.hippo4j.springboot.starter.adapter.rabbitmq.example"}) +public class ServerAdapterRabbitMQExampleApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerAdapterRabbitMQExampleApplication.class, args); + } +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQTemplateConfig.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQTemplateConfig.java new file mode 100644 index 00000000..b517e05a --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQTemplateConfig.java @@ -0,0 +1,44 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example.config; + +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * RabbitMQ template config. + */ +@Configuration +public class RabbitMQTemplateConfig { + + @Bean + public RabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) { + RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); + rabbitTemplate.setMessageConverter(jackson2JsonMessageConverter()); + return rabbitTemplate; + } + + @Bean + public MessageConverter jackson2JsonMessageConverter() { + return new Jackson2JsonMessageConverter(); + } +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQThreadPoolConfig.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQThreadPoolConfig.java new file mode 100644 index 00000000..7eb4f6b4 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/config/RabbitMQThreadPoolConfig.java @@ -0,0 +1,65 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example.config; + +import org.springframework.amqp.rabbit.config.AbstractRabbitListenerContainerFactory; +import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory; +import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +/** + * RabbitMQ thread-pool config. + */ +@Configuration +public class RabbitMQThreadPoolConfig { + + private static final int MAX_POOL_SIZE = 5; + + private static final int CORE_POOL_SIZE = 5; + + private static final int QUEUE_CAPACITY = 1000; + + private static final int CONSUMERS_PER_QUEUE = 10; + + @Bean + public ThreadPoolTaskExecutor rabbitListenerTaskExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + // Specify the maximum number of threads. + executor.setMaxPoolSize(MAX_POOL_SIZE); + // Specifies the minimum number of thread pool maintenance threads. + executor.setCorePoolSize(CORE_POOL_SIZE); + // Specifies the number of tasks waiting to be processed. + executor.setQueueCapacity(QUEUE_CAPACITY); + executor.setThreadNamePrefix("RabbitListenerTaskExecutor-"); + return executor; + } + + @Bean + public AbstractRabbitListenerContainerFactory defaultRabbitListenerContainerFactory(ThreadPoolTaskExecutor rabbitListenerTaskExecutor, + MessageConverter messageConverter, AbstractConnectionFactory abstractConnectionFactory) { + DirectRabbitListenerContainerFactory factory = new DirectRabbitListenerContainerFactory(); + factory.setConnectionFactory(abstractConnectionFactory); + factory.setMessageConverter(messageConverter); + factory.setConsumersPerQueue(CONSUMERS_PER_QUEUE); + abstractConnectionFactory.setExecutor(rabbitListenerTaskExecutor); + return factory; + } +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/constants/SimpleMQConstant.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/constants/SimpleMQConstant.java new file mode 100644 index 00000000..2d12c40b --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/constants/SimpleMQConstant.java @@ -0,0 +1,26 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example.constants; + +/** + * Simple MQ constant. + */ +public class SimpleMQConstant { + + public static final String QUEUE_NAME = "framework_message-center_queue"; +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/consumer/MessageConsumer.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/consumer/MessageConsumer.java new file mode 100644 index 00000000..b4ae7bd9 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/consumer/MessageConsumer.java @@ -0,0 +1,46 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example.consumer; + +import cn.hippo4j.example.core.dto.SendMessageDTO; +import cn.hippo4j.springboot.starter.adapter.rabbitmq.example.constants.SimpleMQConstant; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +/** + * Message consume. + */ +@Slf4j +@Component +public class MessageConsumer { + + @RabbitHandler + @RabbitListener(queuesToDeclare = @Queue(SimpleMQConstant.QUEUE_NAME), containerFactory = "defaultRabbitListenerContainerFactory") + public void receiveObject(SendMessageDTO simple) throws Exception { + TimeUnit.SECONDS.sleep(1); + ObjectMapper objectMapper = new ObjectMapper(); + String message = objectMapper.writeValueAsString(simple); + log.info("consumer1 threadId {} Message: {}", Thread.currentThread().getName(), message); + } +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/producer/MessageProduce.java b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/producer/MessageProduce.java new file mode 100644 index 00000000..978f4ce4 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/rabbitmq/example/producer/MessageProduce.java @@ -0,0 +1,54 @@ +/* + * 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.springboot.starter.adapter.rabbitmq.example.producer; + +import cn.hippo4j.common.toolkit.IdUtil; +import cn.hippo4j.example.core.dto.SendMessageDTO; +import cn.hippo4j.springboot.starter.adapter.rabbitmq.example.constants.SimpleMQConstant; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Message produce. + */ +@Slf4j +@Component +@RestController +@AllArgsConstructor +public class MessageProduce { + + private final RabbitTemplate rabbitTemplate; + + @GetMapping("/message/send") + public String sendMessage(@RequestParam(name = "count") Integer count) { + for (int i = 0; i < count; i++) { + String keys = IdUtil.randomUUID(); + SendMessageDTO payload = SendMessageDTO.builder() + .receiver("156011xxx91") + .uid(keys) + .build(); + rabbitTemplate.convertAndSend(SimpleMQConstant.QUEUE_NAME, payload); + } + return "success"; + } +} diff --git a/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/resources/application.properties b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/resources/application.properties new file mode 100644 index 00000000..f3bc5fd4 --- /dev/null +++ b/examples/threadpool-example/server/adapter-rabbitmq-spring-boot3/src/main/resources/application.properties @@ -0,0 +1,17 @@ +server.port=8091 + +spring.profiles.active=dev +spring.application.name=hippo4j-spring-boot-starter-adapter-rabbitmq-spring-boot3-example + +spring.dynamic.thread-pool.server-addr=http://localhost:6691 +spring.dynamic.thread-pool.namespace=prescription +spring.dynamic.thread-pool.item-id=dynamic-threadpool-example +spring.dynamic.thread-pool.username=admin +spring.dynamic.thread-pool.password=123456 + +# Please replace the local configuration. +spring.rabbitmq.host=127.0.0.1 +spring.rabbitmq.port=5672 +spring.rabbitmq.username=guest +spring.rabbitmq.password=guest +spring.rabbitmq.virtual-host=/ diff --git a/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/README.md b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/README.md new file mode 100644 index 00000000..5a267d79 --- /dev/null +++ b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/README.md @@ -0,0 +1,5 @@ +## spring-boot3 仅支持jdk17以上版本 +## 启动项添加JVM配置参数: +``` +--add-opens java.base/java.util.concurrent=ALL-UNNAMED +``` \ No newline at end of file diff --git a/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/pom.xml b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/pom.xml new file mode 100644 index 00000000..64f72234 --- /dev/null +++ b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-threadpool-adapter-stream-rabbitmq-spring-boot3-example + ${revision} + + true + 2.0.0-SNAPSHOT + 3.3.3 + 4.1.3 + 1.17 + 17 + 17 + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter-adapter-stream-rabbitmq + ${project.version} + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter + ${project.version} + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + org.springframework.cloud + spring-cloud-starter-stream-rabbit + ${spring-clound-stream.version} + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java new file mode 100644 index 00000000..45883273 --- /dev/null +++ b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java @@ -0,0 +1,71 @@ +/* + * 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.springboot.starter.adapter.springcloud.stream.rabbitmq.example; + +import cn.hippo4j.common.toolkit.IdUtil; +import cn.hippo4j.common.toolkit.JSONUtil; +import cn.hippo4j.example.core.dto.SendMessageDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.stream.function.StreamBridge; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * Message produce. + */ +@Slf4j +@RestController +@AllArgsConstructor +public class MessageProduce { + + private final StreamBridge streamBridge; + + private static final int MAX_SEND_SIZE = 10; + + @GetMapping("/message/send") + public String sendMessage(@RequestParam(required = false,name = "maxSendSize") Integer maxSendSize) { + if (maxSendSize == null) { + maxSendSize = MAX_SEND_SIZE; + } + for (int i = 0; i < maxSendSize; i++) { + sendMessage0(); + } + return "success"; + } + + private void sendMessage0() { + String keys = IdUtil.randomUUID(); + SendMessageDTO payload = SendMessageDTO.builder() + .receiver("156011xxx91") + .uid(keys) + .build(); + long startTime = System.currentTimeMillis(); + boolean sendResult = false; + try { + sendResult = streamBridge.send("demoOutput", payload); + } finally { + log.info("Send status: {}, Keys: {}, Execute time: {} ms, Message: {}", + sendResult, + keys, + System.currentTimeMillis() - startTime, + JSONUtil.toJSONString(payload)); + } + } +} diff --git a/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java new file mode 100644 index 00000000..1f974800 --- /dev/null +++ b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java @@ -0,0 +1,55 @@ +/* + * 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.springboot.starter.adapter.springcloud.stream.rabbitmq.example; + +import cn.hippo4j.common.toolkit.JSONUtil; +import cn.hippo4j.core.enable.EnableDynamicThreadPool; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.support.AmqpHeaders; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageHeaders; + +import java.util.function.Consumer; + +/** + * Server Adapter Spring Cloud Stream RabbitMQ Application + */ +@Slf4j +@EnableDynamicThreadPool +@SpringBootApplication +public class ServerAdapterSpringCloudStreamRabbitMQApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerAdapterSpringCloudStreamRabbitMQApplication.class, args); + } + + @Bean + public Consumer> demoInput() { + return message -> { + MessageHeaders headers = message.getHeaders(); + log.info("Input current thread name: {} ,{} received from partition {}", + Thread.currentThread().getName(), + JSONUtil.toJSONString(message.getPayload()), + headers.get(AmqpHeaders.CONSUMER_QUEUE)); + }; + } + +} diff --git a/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/resources/application.properties b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/resources/application.properties new file mode 100644 index 00000000..075e4ff8 --- /dev/null +++ b/examples/threadpool-example/server/adapter-stream-rabbitmq-spring-boot3/src/main/resources/application.properties @@ -0,0 +1,29 @@ +server.port=8090 + +spring.application.name=hippo4j-spring-boot-starter-adapter-rabbitmq-spring-boot3-example + +spring.profiles.active=dev +spring.dynamic.thread-pool.server-addr=http://localhost:6691 +spring.dynamic.thread-pool.namespace=prescription +spring.dynamic.thread-pool.item-id=dynamic-threadpool-example +spring.dynamic.thread-pool.username=admin +spring.dynamic.thread-pool.password=123456 + +spring.rabbitmq.host=localhost +spring.rabbitmq.port=5672 +spring.rabbitmq.username=root +spring.rabbitmq.password=123456 +spring.rabbitmq.virtual-host=/ + +# Please replace the local configuration. +spring.cloud.stream.binders.defaultRabbit.type=rabbit + +# === produce === +spring.cloud.stream.bindings.demoOutput.destination=exchange-demo +spring.cloud.stream.bindings.demoOutput.content-type=application/json + +# === consume === +spring.cloud.stream.bindings.demoInput-in-0.destination=exchange-demo +spring.cloud.stream.bindings.demoInput-in-0.content-type=application/json +spring.cloud.stream.bindings.demoInput-in-0.group=myGroup +spring.cloud.stream.bindings.demoInput-in-0.consumer.concurrency=1 diff --git a/examples/threadpool-example/server/server-spring-boot3/README.md b/examples/threadpool-example/server/server-spring-boot3/README.md new file mode 100644 index 00000000..30067dd5 --- /dev/null +++ b/examples/threadpool-example/server/server-spring-boot3/README.md @@ -0,0 +1,4 @@ +启动项添加JVM配置参数: +``` +--add-opens java.base/java.util.concurrent=ALL-UNNAMED +``` \ No newline at end of file diff --git a/examples/threadpool-example/server/server-spring-boot3/pom.xml b/examples/threadpool-example/server/server-spring-boot3/pom.xml new file mode 100644 index 00000000..e5df15cb --- /dev/null +++ b/examples/threadpool-example/server/server-spring-boot3/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + cn.hippo4j + hippo4j-threadpool-server-spring-boot3-example + ${revision} + + 2.0.0-SNAPSHOT + true + 3.3.3 + 1.17 + 17 + 17 + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + cn.hippo4j + hippo4j-example-core + ${revision} + + + + cn.hippo4j + hippo4j-threadpool-spring-boot-starter + ${revision} + + + + io.micrometer + micrometer-registry-prometheus + + + + org.springframework.boot + spring-boot-starter-actuator + + + + cn.hippo4j + hippo4j-spring-boot-starter-monitor-micrometer + ${revision} + + + + org.springframework.boot + spring-boot-starter-web + + + + org.apache.tomcat.embed + tomcat-embed-core + + + + + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/examples/threadpool-example/server/server-spring-boot3/src/main/java/cn/hippo4j/example/server/ServerExampleApplication.java b/examples/threadpool-example/server/server-spring-boot3/src/main/java/cn/hippo4j/example/server/ServerExampleApplication.java new file mode 100644 index 00000000..23d6ed17 --- /dev/null +++ b/examples/threadpool-example/server/server-spring-boot3/src/main/java/cn/hippo4j/example/server/ServerExampleApplication.java @@ -0,0 +1,34 @@ +/* + * 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.example.server; + +import cn.hippo4j.core.enable.EnableDynamicThreadPool; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Server Example Application + */ +@EnableDynamicThreadPool +@SpringBootApplication(scanBasePackages = {"cn.hippo4j.example.core", "cn.hippo4j.example.server"}) +public class ServerExampleApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerExampleApplication.class, args); + } +} diff --git a/examples/threadpool-example/server/server-spring-boot3/src/main/resources/META-INF/services/cn.hippo4j.common.executor.support.CustomRejectedExecutionHandler b/examples/threadpool-example/server/server-spring-boot3/src/main/resources/META-INF/services/cn.hippo4j.common.executor.support.CustomRejectedExecutionHandler new file mode 100644 index 00000000..bf4970df --- /dev/null +++ b/examples/threadpool-example/server/server-spring-boot3/src/main/resources/META-INF/services/cn.hippo4j.common.executor.support.CustomRejectedExecutionHandler @@ -0,0 +1 @@ +cn.hippo4j.example.core.handler.ErrorLogRejectedExecutionHandler \ No newline at end of file diff --git a/examples/threadpool-example/server/server-spring-boot3/src/main/resources/application.properties b/examples/threadpool-example/server/server-spring-boot3/src/main/resources/application.properties new file mode 100644 index 00000000..0c8d952e --- /dev/null +++ b/examples/threadpool-example/server/server-spring-boot3/src/main/resources/application.properties @@ -0,0 +1,26 @@ +server.port=8088 +debug=true +server.servlet.context-path=/example + +management.prometheus.metrics.export.enabled=true +management.server.port=29901 +management.endpoints.web.exposure.include=* + +spring.profiles.active=dev +spring.application.name=hippo4j-spring-boot3-starter-example + +spring.dynamic.thread-pool.server-addr=http://localhost:6691 +### Use netty to report thread pool monitoring data. The default is http. +# spring.dynamic.thread-pool.report-type=netty +# spring.dynamic.thread-pool.netty-server-port=8899 +spring.dynamic.thread-pool.namespace=prescription +spring.dynamic.thread-pool.item-id=dynamic-threadpool-example +spring.dynamic.thread-pool.username=admin +spring.dynamic.thread-pool.password=123456 + +# Enable server and micrometer monitoring at the same time +spring.dynamic.thread-pool.monitor.enable=true +spring.dynamic.thread-pool.monitor.collect-types=server,micrometer +spring.dynamic.thread-pool.monitor.thread-pool-types=dynamic,web +spring.dynamic.thread-pool.monitor.initial-delay=10000 +spring.dynamic.thread-pool.monitor.collect-interval=5000 diff --git a/starters/threadpool/adapter/alibaba-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/alibaba-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..942e3b44 --- /dev/null +++ b/starters/threadpool/adapter/alibaba-dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.alibaba.dubbo.AlibabaDubboAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..83ec2e6d --- /dev/null +++ b/starters/threadpool/adapter/dubbo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.dubbo.DubboAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/dubbox/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/dubbox/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..dea260cf --- /dev/null +++ b/starters/threadpool/adapter/dubbox/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.dubbo.DubboxAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/hystrix/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/hystrix/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..568db5a4 --- /dev/null +++ b/starters/threadpool/adapter/hystrix/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.hystrix.HystrixAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/kafka/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/kafka/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..11a91b8c --- /dev/null +++ b/starters/threadpool/adapter/kafka/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.kafka.KafkaAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..6f373cd3 --- /dev/null +++ b/starters/threadpool/adapter/rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.rabbitmq.RabbitMQAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..b418f693 --- /dev/null +++ b/starters/threadpool/adapter/rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.rocketmq.RocketMQAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/stream-rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/stream-rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..42a97f8f --- /dev/null +++ b/starters/threadpool/adapter/stream-rabbitmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.springcloud.stream.rabbitmq.SpringCloudStreamRabbitMQAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/stream-rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/stream-rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..82dd1a2e --- /dev/null +++ b/starters/threadpool/adapter/stream-rocketmq/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.adapter.springcloud.stream.rocketmq.SpringCloudStreamRocketMQAdapterAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebAdapterConfiguration.java b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebAdapterConfiguration.java new file mode 100644 index 00000000..3665a347 --- /dev/null +++ b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebAdapterConfiguration.java @@ -0,0 +1,69 @@ +/* + * 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.springboot3.starter.adapter.web; + +import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose; +import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler; +import cn.hippo4j.core.config.ApplicationContextHolder; +import cn.hippo4j.core.config.UtilAutoConfiguration; +import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler; +import cn.hippo4j.core.toolkit.inet.InetUtils; +import cn.hippo4j.springboot.starter.adapter.web.WebThreadPoolHandlerConfiguration; +import lombok.RequiredArgsConstructor; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.core.env.ConfigurableEnvironment; + +/** + * Web adapter auto configuration. + */ +@Configuration +@Import({cn.hippo4j.springboot3.starter.adapter.web.WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class, + cn.hippo4j.springboot3.starter.adapter.web.WebThreadPoolHandlerConfiguration.EmbeddedJetty.class, + cn.hippo4j.springboot3.starter.adapter.web.WebThreadPoolHandlerConfiguration.EmbeddedUndertow.class}) +@RequiredArgsConstructor +@AutoConfigureAfter(UtilAutoConfiguration.class) +public class WebAdapterConfiguration { + + private final ConfigurableEnvironment environment; + + @Bean + @ConditionalOnMissingBean + public ApplicationContextHolder simpleApplicationContextHolder() { + return new ApplicationContextHolder(); + } + + @Bean + public WebThreadPoolRunStateHandler webThreadPoolRunStateHandler() { + return new WebThreadPoolRunStateHandler(); + } + + @Bean + @SuppressWarnings("all") + public ThreadPoolRunStateHandler threadPoolRunStateHandler(InetUtils hippo4jInetUtils) { + return new ThreadPoolRunStateHandler(hippo4jInetUtils, environment); + } + + @Bean + public WebThreadPoolHandlerChoose webThreadPoolServiceChoose() { + return new WebThreadPoolHandlerChoose(); + } +} diff --git a/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebThreadPoolHandlerConfiguration.java b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebThreadPoolHandlerConfiguration.java new file mode 100644 index 00000000..497e4d68 --- /dev/null +++ b/starters/threadpool/adapter/web/src/main/java/cn/hippo4j/springboot3/starter/adapter/web/WebThreadPoolHandlerConfiguration.java @@ -0,0 +1,87 @@ +/* + * 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.springboot3.starter.adapter.web; + +import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler; +import cn.hippo4j.adapter.web.jetty.DefaultJettyWebThreadPoolHandler; +import cn.hippo4j.adapter.web.jetty.JettyWebThreadPoolHandlerAdapt; +import cn.hippo4j.adapter.web.tomcat.DefaultTomcatWebThreadPoolHandler; +import cn.hippo4j.adapter.web.tomcat.TomcatWebThreadPoolHandlerAdapt; +import cn.hippo4j.adapter.web.undertow.DefaultUndertowWebThreadPoolHandler; +import cn.hippo4j.adapter.web.undertow.UndertowWebThreadPoolHandlerAdapt; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SearchStrategy; +import org.springframework.boot.web.embedded.jetty.ConfigurableJettyWebServerFactory; +import org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory; +import org.springframework.boot.web.embedded.undertow.ConfigurableUndertowWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Web Thread Pool Handler Configuration + **/ +@Configuration(proxyBeanMethods = false) +public class WebThreadPoolHandlerConfiguration { + + /** + * embedded tomcat + */ + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(name = {"org.apache.catalina.startup.Tomcat", "org.apache.coyote.UpgradeProtocol", "jakarta.servlet.Servlet"}) + @ConditionalOnBean(value = ConfigurableTomcatWebServerFactory.class, search = SearchStrategy.CURRENT) + @ConditionalOnMissingBean({DefaultTomcatWebThreadPoolHandler.class, TomcatWebThreadPoolHandlerAdapt.class}) + static class EmbeddedTomcat { + + @Bean + public TomcatWebThreadPoolHandlerAdapt tomcatWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { + return new DefaultTomcatWebThreadPoolHandler(webThreadPoolRunStateHandler); + } + } + + /** + * embedded jetty + */ + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(name = {"jakarta.servlet.Servlet", "org.eclipse.jetty.server.Server", "org.eclipse.jetty.util.Loader", "org.eclipse.jetty.ee10.webapp.WebAppContext"}) + @ConditionalOnBean(value = ConfigurableJettyWebServerFactory.class, search = SearchStrategy.CURRENT) + @ConditionalOnMissingBean({DefaultJettyWebThreadPoolHandler.class, JettyWebThreadPoolHandlerAdapt.class}) + static class EmbeddedJetty { + + @Bean + public JettyWebThreadPoolHandlerAdapt jettyWebThreadPoolHandler() { + return new DefaultJettyWebThreadPoolHandler(); + } + } + + /** + * embedded undertow + */ + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(name = {"jakarta.servlet.Servlet", "org.xnio.SslClientAuthMode", "io.undertow.Undertow"}) + @ConditionalOnBean(value = ConfigurableUndertowWebServerFactory.class, search = SearchStrategy.CURRENT) + @ConditionalOnMissingBean({DefaultUndertowWebThreadPoolHandler.class, UndertowWebThreadPoolHandlerAdapt.class}) + static class EmbeddedUndertow { + + @Bean + public UndertowWebThreadPoolHandlerAdapt undertowWebThreadPoolHandler(WebThreadPoolRunStateHandler webThreadPoolRunStateHandler) { + return new DefaultUndertowWebThreadPoolHandler(webThreadPoolRunStateHandler); + } + } +} diff --git a/starters/threadpool/adapter/web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/adapter/web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..8335f20c --- /dev/null +++ b/starters/threadpool/adapter/web/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot3.starter.adapter.web.WebAdapterConfiguration \ No newline at end of file diff --git a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/AbstractConfigThreadPoolDynamicRefresh.java b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/AbstractConfigThreadPoolDynamicRefresh.java index 67d82d98..f310bc50 100644 --- a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/AbstractConfigThreadPoolDynamicRefresh.java +++ b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/AbstractConfigThreadPoolDynamicRefresh.java @@ -27,9 +27,9 @@ import cn.hippo4j.threadpool.dynamic.mode.config.parser.ConfigParserHandler; import cn.hippo4j.threadpool.dynamic.mode.config.properties.BootstrapConfigProperties; import cn.hippo4j.threadpool.dynamic.mode.config.refresher.BootstrapConfigPropertiesBinderAdapter; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; +import org.springframework.beans.factory.InitializingBean; import java.util.HashMap; import java.util.Map; @@ -40,7 +40,7 @@ import java.util.concurrent.ExecutorService; * Abstract config thread-pool dynamic refresh. */ @Slf4j -public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh, InitializingBean, ApplicationRunner { +public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh, ApplicationRunner { private final BootstrapConfigPropertiesBinderAdapter bootstrapConfigPropertiesBinderAdapter; protected BootstrapPropertiesInterface bootstrapConfigProperties; @@ -76,17 +76,14 @@ public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPo ApplicationContextHolder.getInstance().publishEvent(new ThreadPoolConfigDynamicRefreshEvent(this, configProperties)); } + @Override - public void afterPropertiesSet() { + public void run(ApplicationArguments args) { try { registerListener(); } catch (Exception ex) { log.error("Hippo4j failed to initialize register listener.", ex); } - } - - @Override - public void run(ApplicationArguments args) { try { publishDynamicThreadPoolEvent((BootstrapConfigProperties) bootstrapConfigProperties); } catch (Exception ex) { diff --git a/starters/threadpool/config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..dff6abf1 --- /dev/null +++ b/starters/threadpool/config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,4 @@ +cn.hippo4j.config.springboot.starter.config.DynamicThreadPoolAutoConfiguration +cn.hippo4j.core.config.UtilAutoConfiguration +cn.hippo4j.message.config.MessageConfiguration +cn.hippo4j.config.springboot.starter.config.MonitorConfiguration \ No newline at end of file diff --git a/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..c3bef7ad --- /dev/null +++ b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-elasticsearch/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.monitor.elasticsearch.ElasticSearchMonitorAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..54adbd04 --- /dev/null +++ b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-local-log/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.monitor.local.log.LocalLogMonitorAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..74f85afc --- /dev/null +++ b/starters/threadpool/monitor/hippo4j-spring-boot-starter-monitor-micrometer/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.monitor.micrometer.MicrometerMonitorAutoConfiguration \ No newline at end of file diff --git a/starters/threadpool/server/pom.xml b/starters/threadpool/server/pom.xml index dd07cde8..04636137 100644 --- a/starters/threadpool/server/pom.xml +++ b/starters/threadpool/server/pom.xml @@ -86,5 +86,10 @@ hippo4j-threadpool-kernel-alarm ${project.version} + + + javax.annotation + javax.annotation-api + diff --git a/starters/threadpool/server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/starters/threadpool/server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..868f4b74 --- /dev/null +++ b/starters/threadpool/server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.springboot.starter.config.DynamicThreadPoolAutoConfiguration \ No newline at end of file diff --git a/threadpool/adapter/dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java b/threadpool/adapter/dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java index cca28fb0..b387d41b 100644 --- a/threadpool/adapter/dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java +++ b/threadpool/adapter/dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java @@ -109,9 +109,9 @@ public class DubboThreadPoolAdapter implements ThreadPoolAdapter, ApplicationLis return; } ExecutorRepository executorRepository = ExtensionLoader.getExtensionLoader(ExecutorRepository.class).getDefaultExtension(); - ConcurrentMap> data = - (ConcurrentMap>) ReflectUtil.getFieldValue(executorRepository, "data"); - ConcurrentMap executorServiceMap = data.get(poolKey); + ConcurrentMap> data = + (ConcurrentMap>) ReflectUtil.getFieldValue(executorRepository, "data"); + ConcurrentMap executorServiceMap = data.get(poolKey); executorServiceMap.forEach((key, value) -> dubboProtocolExecutor.put(String.valueOf(key), (ThreadPoolExecutor) value)); } catch (Exception ex) { log.error("Failed to get Dubbo {} protocol thread pool", Version.getVersion(), ex); diff --git a/threadpool/core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/threadpool/core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..975dcdd5 --- /dev/null +++ b/threadpool/core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cn.hippo4j.core.extension.support.ExtensionAutoConfiguration \ No newline at end of file