lhotari commented on code in PR #25010:
URL: https://github.com/apache/pulsar/pull/25010#discussion_r2689870899


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -4833,13 +4795,23 @@ public Optional<TopicName> getShadowSourceTopic() {
     protected boolean isExceedMaximumDeliveryDelay(ByteBuf headersAndPayload) {
         if (isDelayedDeliveryEnabled()) {
             long maxDeliveryDelayInMs = getDelayedDeliveryMaxDelayInMillis();
-            if (maxDeliveryDelayInMs > 0) {
-                headersAndPayload.markReaderIndex();
-                MessageMetadata msgMetadata = 
Commands.parseMessageMetadata(headersAndPayload);
-                headersAndPayload.resetReaderIndex();
-                return msgMetadata.hasDeliverAtTime()
-                        && msgMetadata.getDeliverAtTime() - 
msgMetadata.getPublishTime() > maxDeliveryDelayInMs;
+            Integer messageTTLInSeconds = 
topicPolicies.getMessageTTLInSeconds().get();
+            if (maxDeliveryDelayInMs <= 0 && (messageTTLInSeconds == null || 
messageTTLInSeconds <= 0)) {
+                return false;
+            }
+            headersAndPayload.markReaderIndex();
+            MessageMetadata msgMetadata = 
Commands.parseMessageMetadata(headersAndPayload);
+            headersAndPayload.resetReaderIndex();

Review Comment:
   One side-effect of this change is that the message metadata would get parsed 
when TTL is set. It has a small performance overhead compared to the previous 
behavior. Therefore, it would be useful to be able to disable this feature 
completely.



-- 
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