Skip to content

[ISSUE #6601]šŸš€DefaultLitePullConsumerImpl with message polling and offset management improvements#6602

Merged
rocketmq-rust-bot merged 1 commit intomainfrom
feat-6601
Mar 1, 2026
Merged

[ISSUE #6601]šŸš€DefaultLitePullConsumerImpl with message polling and offset management improvements#6602
rocketmq-rust-bot merged 1 commit intomainfrom
feat-6601

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Mar 1, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • Added message polling with timeout support for lite pull consumers.
    • Added offset commit operations for managing queue subscriptions (commit all queues, single queue, or multiple queues).
    • Added queue assignment visibility and pause/resume controls for selective queue consumption.

@rocketmq-rust-bot rocketmq-rust-bot self-requested a review March 1, 2026 08:25
@rocketmq-rust-bot
Copy link
Collaborator

šŸ”Š@mxsm šŸš€Thanks for your contributionšŸŽ‰ļ¼

šŸ’”CodeRabbit(AI) will review your code firstšŸ”„ļ¼

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code reviewšŸ’„.

@rocketmq-rust-robot rocketmq-rust-robot added the featurešŸš€ Suggest an idea for this project. label Mar 1, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

This PR adds message polling and offset management capabilities to DefaultLitePullConsumerImpl through new public methods including poll(), commit_all(), commit_sync(), commit(), assignment(), pause(), and resume(). It implements persistent offset storage logic for the consumer and updates message request types from Arc<MessageExt> to ArcMut<MessageExt>.

Changes

Cohort / File(s) Summary
Poll and Offset Management
rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs
Added poll() method for message fetching with state checks and auto-commit support. Introduced commit_all(), commit_sync(), and commit() for offset management across single or multiple queues. Implemented assignment(), pause(), and resume() for queue control. Added functional persist_consumer_offset() implementation replacing previous placeholder. Includes helper update_consume_offset() and maybe_auto_commit() for internal offset flow.
Message Type Update
rocketmq-client/src/consumer/consumer_impl/lite_pull_consume_request.rs
Updated message container type from Arc<MessageExt> to ArcMut<MessageExt> across struct field, constructor, and accessor methods (messages(), into_parts()).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Consumer as DefaultLitePullConsumerImpl
    participant OffsetStore
    participant Hooks
    participant MQ as MessageQueue

    Client->>Consumer: poll(timeout_millis)
    Consumer->>Consumer: Validate consumer state
    alt State is running
        Consumer->>Consumer: Check if auto-commit enabled
        alt Auto-commit enabled
            Consumer->>OffsetStore: Commit current offsets
            OffsetStore-->>Consumer: Offsets committed
        end
        Consumer->>MQ: Fetch messages
        MQ-->>Consumer: Messages received
        Consumer->>Consumer: Update consume offset
        Consumer->>Hooks: Invoke post-consume hooks
        Hooks-->>Consumer: Hooks executed
        Consumer-->>Client: Return Vec<ArcMut<MessageExt>>
    else Invalid state
        Consumer-->>Client: Error
    end
Loading

Estimated code review effort

šŸŽÆ 3 (Moderate) | ā±ļø ~20 minutes

Poem

🐰 Hops of joy for polling grace,
Offsets tracked at perfect pace,
Commit and pause with gentle care,
Messages flowing everywhere!
The consumer hops along,
With mutable types, bright and strong! ✨

🚄 Pre-merge checks | āœ… 4 | āŒ 1

āŒ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ā“ Inconclusive The linked issue #6601 contains no feature description, requirements, or acceptance criteria, making it impossible to validate whether code changes meet specific objectives. The linked issue lacks detailed requirements. Verify that the implemented poll(), commit_*(), assignment(), pause(), and resume() methods align with the intended feature scope by referencing issue #6601 directly or requesting clarification.
āœ… Passed checks (4 passed)
Check name Status Explanation
Description Check āœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check āœ… Passed The title references issue #6601 and describes adding message polling and offset management to DefaultLitePullConsumerImpl, which matches the core changes in the PR.
Out of Scope Changes check āœ… Passed All changes (poll, commit methods, assignment, pause/resume, offset persistence) are directly related to DefaultLitePullConsumerImpl's message polling and offset management functionality.
Docstring Coverage āœ… Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%.

āœļø Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • šŸ“ Generate docstrings (stacked PR)
  • šŸ“ Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-6601

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

ā¤ļø Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs (1)

812-823: Consider propagating partial failure information from commit_all().

The method always returns Ok(()) even when all individual commit_sync calls fail. While logging errors is good, callers have no way to detect whether any commits succeeded. If this is intentional best-effort behavior, a brief doc comment would clarify the contract.

šŸ’” Alternative: return summary of failures
-    pub async fn commit_all(&self) -> RocketMQResult<()> {
+    /// Commits offsets for all assigned queues.
+    /// Returns Ok(()) on best-effort basis; individual failures are logged but not propagated.
+    pub async fn commit_all(&self) -> RocketMQResult<()> {
         let queues = self.assigned_message_queue.message_queues().await;
+        let mut failure_count = 0;
 
         for mq in queues {
             if let Err(e) = self.commit_sync(&mq, true).await {
                 tracing::error!("Failed to commit offset for queue {:?}: {}", mq, e);
+                failure_count += 1;
             }
         }
 
+        if failure_count > 0 {
+            tracing::warn!("commit_all completed with {} failures", failure_count);
+        }
         Ok(())
     }
šŸ¤– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`
around lines 812 - 823, commit_all currently swallows all commit_sync failures
and always returns Ok(()), leaving callers unaware of partial or total failures;
update commit_all (and its signature if needed) to propagate failure info by
collecting errors from each commit_sync(&mq, true).await (refer to commit_all
and commit_sync) and returning an Err (or a summary error type) if any
individual commit failed, or alternatively document the method behavior clearly
if best-effort is intentional; implement by aggregating errors (e.g.,
Vec<(MessageQueue, Error)> or a combined error) and returning
RocketMQResult::Err when non-empty so callers can detect partial failures.
šŸ¤– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`:
- Around line 779-783: The loop over consume_message_hook_list is a no-op so
hooks never run; either call the hook method or remove the dead loop: locate the
loop in default_lite_pull_consumer_impl.rs where consume_message_hook_list is
iterated and replace the empty body with invocations of the hook trait's method
(pass the current message(s) and any consumer/context needed per the hook trait,
e.g., call hook.consume_message(consumer, msgs, context) or the actual method
name defined by your ConsumeMessageHook trait), or if hooks are not yet
supported remove the loop and add a TODO explaining future intent.

---

Nitpick comments:
In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`:
- Around line 812-823: commit_all currently swallows all commit_sync failures
and always returns Ok(()), leaving callers unaware of partial or total failures;
update commit_all (and its signature if needed) to propagate failure info by
collecting errors from each commit_sync(&mq, true).await (refer to commit_all
and commit_sync) and returning an Err (or a summary error type) if any
individual commit failed, or alternatively document the method behavior clearly
if best-effort is intentional; implement by aggregating errors (e.g.,
Vec<(MessageQueue, Error)> or a combined error) and returning
RocketMQResult::Err when non-empty so callers can detect partial failures.

ā„¹ļø Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

šŸ“„ Commits

Reviewing files that changed from the base of the PR and between 71ec071 and 491f846.

šŸ“’ Files selected for processing (2)
  • rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs
  • rocketmq-client/src/consumer/consumer_impl/lite_pull_consume_request.rs

Comment on lines +779 to +783
if !self.consume_message_hook_list.is_empty() {
for hook in &self.consume_message_hook_list {
// Execute consume message hooks
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

āš ļø Potential issue | 🟔 Minor

Empty hook execution loop - hooks are not being invoked.

The loop iterates over consume_message_hook_list but the body is empty. Either invoke the hooks or remove the dead code.

šŸ”§ Suggested fix

If hooks should be invoked, implement the call:

 if !self.consume_message_hook_list.is_empty() {
     for hook in &self.consume_message_hook_list {
-        // Execute consume message hooks
+        // TODO: Build ConsumeMessageContext and invoke hook
+        // hook.consume_message_before(&context);
     }
 }

Alternatively, if this is placeholder code, consider removing it entirely until ready to implement, or add a TODO comment outside the loop to clarify intent.

šŸ“ Committable suggestion

ā€¼ļø IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if !self.consume_message_hook_list.is_empty() {
for hook in &self.consume_message_hook_list {
// Execute consume message hooks
}
}
if !self.consume_message_hook_list.is_empty() {
for hook in &self.consume_message_hook_list {
// TODO: Build ConsumeMessageContext and invoke hook
// hook.consume_message_before(&context);
}
}
šŸ¤– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`
around lines 779 - 783, The loop over consume_message_hook_list is a no-op so
hooks never run; either call the hook method or remove the dead loop: locate the
loop in default_lite_pull_consumer_impl.rs where consume_message_hook_list is
iterated and replace the empty body with invocations of the hook trait's method
(pass the current message(s) and any consumer/context needed per the hook trait,
e.g., call hook.consume_message(consumer, msgs, context) or the actual method
name defined by your ConsumeMessageHook trait), or if hooks are not yet
supported remove the loop and add a TODO explaining future intent.

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

āŒ Patch coverage is 0% with 148 lines in your changes missing coverage. Please review.
āœ… Project coverage is 41.63%. Comparing base (71ec071) to head (491f846).
āš ļø Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r/consumer_impl/default_lite_pull_consumer_impl.rs 0.00% 141 Missing āš ļø
...onsumer/consumer_impl/lite_pull_consume_request.rs 0.00% 7 Missing āš ļø
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6602      +/-   ##
==========================================
- Coverage   41.67%   41.63%   -0.05%     
==========================================
  Files         959      959              
  Lines      134135   134280     +145     
==========================================
+ Hits        55904    55907       +3     
- Misses      78231    78373     +142     

ā˜” View full report in Codecov by Sentry.
šŸ“¢ Have feedback on the report? Share it here.

šŸš€ New features to boost your workflow:
  • ā„ļø Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • šŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed āœ…

@rocketmq-rust-bot rocketmq-rust-bot merged commit 768268b into main Mar 1, 2026
18 of 20 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge featurešŸš€ Suggest an idea for this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FeaturešŸš€] DefaultLitePullConsumerImpl with message polling and offset management improvements

3 participants