tikafu commented on issue #21891: URL: https://github.com/apache/pulsar/issues/21891#issuecomment-1891935527
Well, I will provide a complete example to illustrate this issue。 1. The publish time is generated by the internal code of SDK as shown in the example you just gave above. https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java#L584 It is a long type numerical value, an absolute timestamp independent of time zone, there is truly no time zone information in the publishTime field. 2. Then the publish time is sent to pulsar and stored on disk as metadata of the message and it become read only. 3. When you invoke the method PulsarAdmin.topics().getMessageById().getPublishTime() to get the publish time of a special message, the broker will find the entry of this message after receiving request and parse the message's metadata, including its publish time. https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L3051 Then the broker formats this long type timestamp, it should be noted that this operation will use the timezone of the current broker. https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java#L3070 4. As so far, the publish time has been formatted as a STRING type value from the absolute timestamp and is added to http headers which will be sent to the admin client. 5. Now let's take a look at how the admin client handle this http header in response. https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java#L1292 https://github.com/apache/pulsar/blob/45037399febdcf7208d8cd88bfd75bd2b1074f07/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java#L1294 Obviously, it applies a reverse formatting to this STRING, the publish time was changed back to long type numerical value again, but with the timezone of admin client. 6. Now assuming that the timezones between broker and client are different, will the publish time the admin client get finally be the same as its origin? @lhotari -- 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]
