mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-10-31 10:11:49 +08:00
DC3 Common Thread
Overview
dc3-common-thread is the shared thread pool module of the IoT DC3 platform. It exposes a set of JDK executor beans
(configured from the dc3.thread properties) that other modules inject explicitly for background work such as
concurrent point reads and batch message handling.
Module Information
- Group ID: io.github.pnoker
- Artifact ID: dc3-common-thread
Key Components
| Component | Purpose |
|---|---|
ThreadPoolConfig |
Provides three executor beans — threadPoolExecutor (ThreadPoolExecutor), virtualThreadExecutor (virtual-thread ExecutorService), scheduledThreadPoolExecutor (ScheduledThreadPoolExecutor) — sharing a caller-runs rejection handler |
ThreadProperties |
Binds thread pool properties from YAML (prefix dc3.thread: prefix, corePoolSize, maximumPoolSize, keepAliveTime) |
ThreadInitRunner |
Startup log for confirming thread pool initialization |
Configuration Properties
dc3:
thread:
prefix: dc3-thread-
core-pool-size: 4
maximum-pool-size: 32
keep-alive-time: 15
Usage
Inject the executor you need, for example virtualThreadExecutor in MqttScheduleJob, or threadPoolExecutor in
DriverReadScheduleJob. Data services also inject the shared executors for concurrent persistence and message work.
Note: Spring's
@Asyncdoes not use these beans — it runs on Spring Boot's defaultapplicationTaskExecutor. These executors are obtained by explicit constructor injection, not via@Async.
Build Instructions
mvn -s .mvn/settings.xml -pl dc3-common/dc3-common-thread -am package
Testing
Run the module tests from the repository root:
mvn -s .mvn/settings.xml -pl dc3-common/dc3-common-thread -am test
Related Modules
dc3-common-data/dc3-common-mqtt— injectvirtualThreadExecutorfor batch persistence / message handlingdc3-common-driver— injectsthreadPoolExecutorfor concurrent device readsdc3-driver-opc-da— injectsscheduledThreadPoolExecutor