AlNedorezov opened a new issue #12733: URL: https://github.com/apache/pulsar/issues/12733
**Describe the bug** For messages got via pulsarAdmin.topics().peekMessages(topic, subscription, total) method from pulsar-client-admin, getKey() method always returns an empty string. **To Reproduce** Steps to reproduce the behavior: 1. Write some messages with specified message keys to a topic 2. Call pulsarAdmin.topics().peekMessages(topic, subscription, total); (pulsarAdmin is an instance of org.apache.pulsar.client.admin.PulsarAdmin) 3. For a message from a list of message received on previous step call getKey() method 4. empty string will be returned **Expected behavior** getKey() method should return a message key. **Screenshots** E.g. of getKey() result for a peeked message:  E.g. of getKey() result for the same message which was received:  **Desktop (please complete the following information):** we are using pulsar-client-admin v2.7.2 ``` <dependency> <groupId>org.apache.pulsar</groupId> <artifactId>pulsar-client-admin</artifactId> <version>2.7.2</version> </dependency> ``` **Additional context** A bit of a shot in the dark, but I think this happens because for peeked message getKey() returns a partiton key from metadata, but not the actual key itself. See org.apache.pulsar.client.impl.MessageImpl:  AFAIK pulsar-admin java client uses pulsar-admin rest api, and API doesn't actually return a key, only metadata.getPartitionKey(). See https://github.com/apache/pulsar/blob/a2b7cae3cfe8d3776483b1ecaf69af47949b70e1/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L2595 -- 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]
