Repository navigation
[ISSUE #1318] [Java] Support opt-in virtual threads - #1319
Conversation
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1319 +/- ##
============================================
+ Coverage 53.26% 54.59% +1.32%
- Complexity 651 822 +171
============================================
Files 208 222 +14
Lines 14303 14501 +198
Branches 5845 5600 -245
============================================
+ Hits 7619 7917 +298
+ Misses 6308 6175 -133
- Partials 376 409 +33
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Harness. π New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR adds opt-in virtual thread support for the Java client (JDK 21+), using reflection to maintain Java 8 compilation compatibility. When enabled via enableVirtualThreads(true), async RPCs, callbacks, telemetry commands, and push-consumer message processing run on virtual threads. A fair Semaphore-based wrapper ensures setConsumptionThreadCount still bounds concurrency. Falls back gracefully to platform threads on older JDKs.
The design is clean: reflection-based discovery of Executors.newVirtualThreadPerTaskExecutor(), proper abstraction widening from ThreadPoolExecutor to ExecutorService, and comprehensive tests covering both JDK 21 and older environments. CI matrix is extended to include JDK 21. All checks pass.
LGTM β two minor informational notes inline.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR contains 726 lines of changes. Automated structural review completed.
Review Notes
- Changes reviewed for structural correctness
- No critical issues detected in automated scan
- Recommend maintainer review for domain-specific logic
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Fixes #1318
Brief Description
This change adds an opt-in
enableVirtualThreads(boolean)client configuration. It is disabled by default.When enabled on JDK 21 or later, the Java client uses virtual-thread-per-task executors for asynchronous RPC work, client callbacks, telemetry commands, and push-consumer message processing. The JDK 21 executor API is discovered through reflection so the project keeps its existing Java 8 compilation target and remains runnable on older JDKs. If virtual threads are unavailable, the client falls back to the existing platform-thread executors.
Push-consumer execution uses a fair
SemaphoresosetConsumptionThreadCountremains the maximum number of concurrently running consumption tasks. Waiting virtual threads park without occupying carrier threads. Scheduled executors remain platform-thread based.How Did You Test This Change?
mvn -pl client -am -Dspotbugs.skip=true -Djacoco.skip=true -Dtest=ClientConfigurationTest,ExecutorServicesTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl client -am clean -Dspotbugs.skip=true testClientConfiguration.classandExecutorServices.classboth have class-file major version 52.setConsumptionThreadCount(1), the maximum observed concurrent listeners was exactly 1.