lovelle commented on a change in pull request #3267: Support set publish time
on broker side
URL: https://github.com/apache/pulsar/pull/3267#discussion_r244547469
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java
##########
@@ -148,12 +149,17 @@ public void publishMessage(long producerId, long
sequenceId, ByteBuf headersAndP
return;
}
- if (topic.isEncryptionRequired()) {
+ headersAndPayload.markReaderIndex();
+ MessageMetadata msgMetadata =
Commands.parseMessageMetadata(headersAndPayload);
+ headersAndPayload.resetReaderIndex();
+ if (msgMetadata.getPublishTime() == Constants.PUBLISH_TIME_UNSET_MS) {
Review comment:
Sorry, I didn't explained why I did it that way.
The reason I used a constant of 13 digits size is because the method
`modifyMessageMetadata()` should be able to just update this value without
realloc the entire buffer due to being with different size, the problem with
`hasPublishTime()` is that if it is false then publish time on metadata is
literally '0' and the new epoch will be of 13 digits length.
The alternative approach I can think to get rid of the constant definition
is to set publish time field on protobuf with the default value of 13 digits
and testing if publish time has such default comparing with a new metadata
created.
Maybe proto3 solved this? not really sure.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services