lin-zhao opened a new issue, #17947:
URL: https://github.com/apache/pulsar/issues/17947

   ### Motivation
   
   Currently, `pulsar-admin topics peek-messages` and the REST equivalent 
return the message payload in their original binary form. In the case that the 
topic has a complex schema, for example, AVRO, protobuf-encoded binary is 
returned. This results in two issues.
   
   1. The output can be unreadable with hidden charractors.
   2. The response from the REST API doesn't conform to HTTP standard. Binary 
data are not properly encoded or have the right headers set.
   
   ### Goal
   
   Ability to ask Pulsar broker's Admin API to return properly encoded string 
payload, instead of binary payload.
   
   ### API Changes
   
   1. API 
[/admin/v2/:schema/:tenant/:namespace/:topic/subscription/:subName/position/:messagePosition](https://pulsar.apache.org/admin-rest-api?version=2.10.1&apiversion=v2#operation/peekNthMessage)
 will have an optional query parameter `asString`. Valid values are `true` or 
`false`. When set to be `true`, the returned payload will be encoded according 
to the topic's schema.
   2. `pulsar-admin topics peek-messages` will add an optional flag `--string`. 
If set to `true`, output would have the payload encoded as string per the 
topic's schema.
   
   ### Implementation
   
   When handling `peek` request, broker admin currently first retrieves the 
entry from managed ledger. Then read the binary form from the entry before 
packaging it as part of REST response.
   
   Before the binary is returned, the broker would make a request to 
`schemaRegistryService` asking for the schema from the schema storage. Once 
found, the broker would read the schema and encode the payload accordingly.
   
   ### Alternatives
   
   _No response_
   
   ### Anything else?
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to