hangc0276 commented on a change in pull request #11014: URL: https://github.com/apache/pulsar/pull/11014#discussion_r663302514
########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageImpl.java ########## @@ -269,31 +269,26 @@ public MessageImpl(String topic, String msgId, Map<String, String> properties, return msg; } - public static MessageImpl<byte[]> deserializeBrokerEntryMetaDataFirst( - ByteBuf headersAndPayloadWithBrokerEntryMetadata) throws IOException { - @SuppressWarnings("unchecked") - MessageImpl<byte[]> msg = (MessageImpl<byte[]>) RECYCLER.get(); - - msg.brokerEntryMetadata = + public static long getEntryTimestamp( ByteBuf headersAndPayloadWithBrokerEntryMetadata) throws IOException { + // get broker timestamp first if BrokerEntryMetadata is enabled with AppendBrokerTimestampMetadataInterceptor + BrokerEntryMetadata brokerEntryMetadata = Commands.parseBrokerEntryMetadataIfExist(headersAndPayloadWithBrokerEntryMetadata); - - if (msg.brokerEntryMetadata != null) { - msg.msgMetadata.clear(); - msg.payload = null; - msg.messageId = null; - msg.topic = null; - msg.cnx = null; - msg.properties = Collections.emptyMap(); - return msg; + if (brokerEntryMetadata != null && brokerEntryMetadata.hasBrokerTimestamp()) { + return brokerEntryMetadata.getBrokerTimestamp(); } + // otherwise get the publish_time, + MessageMetadata messageMetadata = new MessageMetadata(); Review comment: MessageMetadata messageMetadata = LOCAL_MESSAGE_METADATA.get(); maybe better. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org