mirror of https://github.com/longtai-cn/hippo4j
parent
41b970a15f
commit
36239e8a4b
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>hippo4j-example</artifactId>
|
||||
<groupId>cn.hippo4j</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hippo4j-config-etcd-spring-boot-starter-example</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hippo4j</groupId>
|
||||
<artifactId>hippo4j-config-spring-boot-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.etcd</groupId>
|
||||
<artifactId>jetcd-core</artifactId>
|
||||
<version>${jetcd.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hippo4j</groupId>
|
||||
<artifactId>hippo4j-example-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -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.config.etcd;
|
||||
|
||||
import cn.hippo4j.core.enable.EnableDynamicThreadPool;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
*@author : wh
|
||||
*@date : 2022/9/2 19:06
|
||||
*@description:
|
||||
*/
|
||||
@EnableDynamicThreadPool
|
||||
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.config")
|
||||
public class ConfigEtcdExampleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigEtcdExampleApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.etcd.config;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import cn.hippo4j.core.executor.DynamicThreadPool;
|
||||
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
*@author : wh
|
||||
*@date : 2022/9/2 19:26
|
||||
*@description:
|
||||
*/
|
||||
@Configuration
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
@DynamicThreadPool
|
||||
public ThreadPoolExecutor messageConsumeDynamicExecutor() {
|
||||
String threadPoolId = "message-consume";
|
||||
ThreadPoolExecutor messageConsumeDynamicExecutor = ThreadPoolBuilder.builder()
|
||||
.threadFactory(threadPoolId)
|
||||
.threadPoolId(threadPoolId)
|
||||
.dynamicPool()
|
||||
.build();
|
||||
return messageConsumeDynamicExecutor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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.example.config.etcd.controller;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*@author : wh
|
||||
*@date : 2022/9/2 19:18
|
||||
*@description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping
|
||||
public class TestController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolExecutor messageConsumeDynamicExecutor;
|
||||
|
||||
|
||||
@GetMapping("test")
|
||||
public void test() {
|
||||
System.out.println(messageConsumeDynamicExecutor.getMaximumPoolSize());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
server.port=8888
|
||||
|
||||
spring.application.name=etcd
|
||||
spring.dynamic.thread-pool.etcd.endpoints = http://127.0.0.1:2379
|
||||
spring.dynamic.thread-pool.etcd.key = /thread
|
||||
spring.dynamic.thread-pool.executors[0].thread-pool-id=message-consume
|
||||
spring.dynamic.thread-pool.executors[0].core-pool-size=3
|
||||
spring.dynamic.thread-pool.executors[0].maximum-pool-size=4
|
||||
spring.dynamic.thread-pool.executors[0].queue-capacity=4
|
||||
spring.dynamic.thread-pool.executors[0].execute-time-out=1000
|
||||
spring.dynamic.thread-pool.executors[0].blocking-queue=LinkedBlockingQueue
|
||||
spring.dynamic.thread-pool.executors[0].rejected-handler=AbortPolicy
|
||||
spring.dynamic.thread-pool.executors[0].keep-alive-time=1000
|
||||
spring.dynamic.thread-pool.executors[0].allow-core-thread-time-out=true
|
||||
spring.dynamic.thread-pool.executors[0].thread-name-prefix=message-consume
|
||||
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=111
|
||||
|
||||
spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT
|
||||
spring.dynamic.thread-pool.notify-platforms[0].secret-key=ac0426a5-c712-474c-9bff-72b8b8f5caff
|
Loading…
Reference in new issue