feat(java): add batch consume support for PushConsumer#1226
Closed
qianye1001 wants to merge 3 commits into
Closed
Conversation
8e76ce6 to
17ab213
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1226 +/- ##
============================================
+ Coverage 53.26% 54.36% +1.09%
- Complexity 651 854 +203
============================================
Files 208 223 +15
Lines 14303 14669 +366
Branches 5845 5617 -228
============================================
+ Hits 7619 7975 +356
+ Misses 6308 6286 -22
- Partials 376 408 +32
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
17ab213 to
7c99677
Compare
83f867c to
6e54d38
Compare
6e54d38 to
7786d7b
Compare
Implement batch consumption support for PushConsumer: - BatchConsumeTask: invokes BatchMessageListener with a list of messages - BatchConsumeService: concurrent batch consumption with shared buffer, flush triggered by count/bytes/timeout - FifoBatchConsumeService: serial batch consumption with per-message retry tracking, partial exhaustion sends individual messages to DLQ while remaining messages continue retrying - Wire up PushConsumerImpl.createConsumeService() for batch mode - Add ConsumeService protected constructor and getters for subclass use - Comprehensive unit tests (16 cases) and integration tests (6 cases) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
Closing in favor of a new PR with improved implementation: cleaner class hierarchy (BatchConsumeService + FifoBatchConsumeService via inheritance), precise batch splitting with forward-progress guarantee, Builder pattern for BatchPolicy, and whole-batch FIFO retry semantics. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Issue(s) This PR Fixes
Fixes #1225
Brief Description
This PR adds first-class batch consumption support for PushConsumer in the Java client, controlled by a
BatchPolicy.PushConsumer — Batch Consume Service
BatchConsumeService: accumulates messages from allProcessQueues into a singleBatchBuffer, flushing toBatchMessageListenerwhen any threshold is met (count, bytes, or timeout).BatchBuffer: encapsulated accumulation buffer with lock-based concurrency, scheduled timeout flush, forward-progress guarantee (single oversized message is still flushed).BatchConsumeTask:Callablethat invokesBatchMessageListenerwith interceptor hooks.BatchMessageListenerinterface andPushConsumerBuilder.setBatchMessageListener().close()flushes all remaining buffered messages before the consumer shuts down.BatchPolicy
Policy with
maxBatchCount,maxBatchBytes,maxWaitTime. Builder pattern with sensible defaults.A batch is flushed when any condition is met:
maxBatchCount.maxBatchBytes.maxWaitTime.How Did You Test This Change?
mvn clean test -pl client-apis,client— 307 tests, 0 failures, 0 checkstyle violations.