Skip to content

[ISSUE #6339]🚀Add producer batch send examples#6340

Merged
mxsm merged 1 commit intomainfrom
feat-6339
Feb 15, 2026
Merged

[ISSUE #6339]🚀Add producer batch send examples#6340
mxsm merged 1 commit intomainfrom
feat-6339

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Feb 15, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • Added a new example demonstrating how to send messages to specific RocketMQ queues. The example showcases five different sending patterns: direct send, send with timeout, send with callback, send with callback and timeout, and one-way send. This provides practical guidance for queue-specific message publishing scenarios.

@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Feb 15, 2026
@rocketmq-rust-bot rocketmq-rust-bot added the AI review first Ai review pr first label Feb 15, 2026
@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💥.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Walkthrough

Adds a new RocketMQ producer example demonstrating queue-specific message sending. The example showcases five sending patterns: direct send, send with timeout, send with callback, send with callback and timeout, and one-way send. Updates the Cargo.toml manifest to register the new example.

Changes

Cohort / File(s) Summary
Example Registration
rocketmq-example/Cargo.toml
Added [[example]] entry registering "producer-send-to-queue" example pointing to the new send_to_queue.rs file.
Queue Sending Example
rocketmq-example/examples/producer/send_to_queue.rs
New example file demonstrating five queue-specific message sending methods via DefaultMQProducer: basic send, send with timeout, send with callback, send with callback and timeout, and one-way send. Includes producer initialization, queue selection, and proper shutdown.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A queue of messages, neat and grand,
Five ways to send them, hand in hand,
With callbacks waiting, timeouts set,
A producer's path, we won't forget! 🚀

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning Title mentions 'batch send examples' but changes add only 'send to queue' examples. The title does not accurately reflect the actual implementation. Update PR title to '[ISSUE #6339] Add producer send to queue examples' to match the actual changes made.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The linked issue #6339 requests examples for producer send to queue functionality, and the PR implements exactly that with five send-to-queue methods.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objective: a new producer send-to-queue example file and corresponding Cargo.toml entry. No unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-6339

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
rocketmq-example/examples/producer/send_to_queue.rs (3)

32-36: Constants don't need pub visibility in an example binary.

Since this is a standalone example binary (not a library), the pub qualifier on these constants is unnecessary. Plain const would suffice.

♻️ Suggested diff
-pub const PRODUCER_GROUP: &str = "producer_send_to_queue";
-pub const DEFAULT_NAMESRVADDR: &str = "127.0.0.1:9876";
-pub const TOPIC: &str = "SendToQueueTestTopic";
-pub const TAG: &str = "QueueTag";
-pub const TIMEOUT_MS: u64 = 3000;
+const PRODUCER_GROUP: &str = "producer_send_to_queue";
+const DEFAULT_NAMESRVADDR: &str = "127.0.0.1:9876";
+const TOPIC: &str = "SendToQueueTestTopic";
+const TAG: &str = "QueueTag";
+const TIMEOUT_MS: u64 = 3000;

140-154: Duplicate callback closures across send_to_queue_with_callback and send_to_queue_with_callback_timeout.

The callback closure on lines 144–148 is identical to lines 177–181. For an example file, inline duplication can be acceptable for readability, but extracting a small helper would reduce copy-paste drift if the example evolves.

♻️ Suggested approach

Define a reusable callback function at the bottom of the file:

fn on_send_complete(result: Option<&SendResult>, error: Option<&dyn std::error::Error>) {
    match (result, error) {
        (Some(r), None) => println!("   Callback: Success - {:?}", r),
        (None, Some(e)) => println!("   Callback: Error - {}", e),
        _ => println!("   Callback: Unknown state"),
    }
}

Then pass on_send_complete in place of the inline closure in both call sites.

Also applies to: 173-188


1-1: Copyright year says 2023 for a file created in 2026.

Very minor nit — the header reads Copyright 2023 but this is a brand-new file. Consider updating to 2026 (or confirming this is the project's standard boilerplate).


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
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 ✅

@mxsm mxsm merged commit 1ac16a0 into main Feb 15, 2026
16 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 Feb 15, 2026
@mxsm mxsm deleted the feat-6339 branch February 22, 2026 05:26
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🚀] Add producer send to queue examples

3 participants