[Bug] Peek nth message REST API returns incorrect data
Search before asking
- [X] I searched in the issues and found nothing similar.
Read release policy
- [X] I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
Version
Pulsar Version:3.3.0 REST API:/persistent/{tenant}/{namespace}/{topic}/subscription/{subName}/position/{messagePosition}
Minimal reproduce step
curl --location --request GET '/admin/v2/persistent/public/default/my-topic/subscription/my-sub/position/1‘
What did you expect to see?
Because the messagePosition parameter is set to 1, a message should normally be returned
What did you see instead?
Multiple messages are returned. It looks like one Batch message. How do I parse this message? I need to display this message on the page
Anything else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
The rest API returns binary data response, not JSON. To decode the message, you have to use Pulsar Client API.
https://github.com/apache/pulsar/blob/679a3d49eefc2a82bbeba085c258b1f2b751f28a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java#L710
https://github.com/apache/pulsar/blob/20e83b96c3fcf10010977ab785093e105e4e40d8/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Topics.java#L1657
Use admin client instead of rest api.
The GUI tool I am developing uses the rest api directly, without the admin client, and I currently do message extraction based on raw data