-
Notifications
You must be signed in to change notification settings - Fork 241
feature: Implement QueryMsgById Command for Message ID-Based Lookup #6750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ use rocketmq_remoting::protocol::header::unlock_batch_mq_request_header::UnlockB | |
| use rocketmq_remoting::protocol::header::unregister_client_request_header::UnregisterClientRequestHeader; | ||
| use rocketmq_remoting::protocol::header::update_consumer_offset_header::UpdateConsumerOffsetRequestHeader; | ||
| use rocketmq_remoting::protocol::header::update_user_request_header::UpdateUserRequestHeader; | ||
| use rocketmq_remoting::protocol::header::view_message_request_header::ViewMessageRequestHeader; | ||
| use rocketmq_remoting::protocol::headers::client::GetConsumerConnectionListRequestHeader; | ||
| use rocketmq_remoting::protocol::headers::view::SearchOffsetRequestHeader; | ||
| use rocketmq_remoting::protocol::headers::view::SearchOffsetResponseHeader; | ||
|
|
@@ -3299,6 +3300,41 @@ impl MQClientAPIImpl { | |
| )) | ||
| } | ||
|
|
||
| pub async fn view_message( | ||
| &mut self, | ||
| addr: &CheetahString, | ||
| request_header: ViewMessageRequestHeader, | ||
| timeout_millis: u64, | ||
| ) -> RocketMQResult<MessageExt> { | ||
| let request = RemotingCommand::create_request_command(RequestCode::ViewMessageById, request_header); | ||
| let response = self | ||
| .remoting_client | ||
| .invoke_request(Some(addr), request, timeout_millis) | ||
| .await?; | ||
|
|
||
| match ResponseCode::from(response.code()) { | ||
| ResponseCode::Success => { | ||
| if let Some(body) = response.get_body() { | ||
| let mut bytes = body.clone(); | ||
| let body_len = bytes.len(); | ||
| MessageDecoder::decode(&mut bytes, true, true, false, false, false).ok_or_else(|| { | ||
| mq_client_err!(format!( | ||
| "Failed to decode message from view_message response body: body_len={}, possible causes: \ | ||
| CRC check failed or malformed message data", | ||
| body_len | ||
| )) | ||
| }) | ||
| } else { | ||
| Err(mq_client_err!("view_message response body is empty".to_string())) | ||
| } | ||
|
Comment on lines
+3315
to
+3329
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid the panicking decoder on broker responses.
🤖 Prompt for AI Agents |
||
| } | ||
| _ => Err(mq_client_err!( | ||
| response.code(), | ||
| response.remark().map_or("".to_string(), |s| s.to_string()) | ||
| )), | ||
| } | ||
| } | ||
|
|
||
| fn build_queue_offset_sorted_map( | ||
| topic: &str, | ||
| msg_found_list: &[MessageExt], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.