Denovo1998 commented on code in PR #25010:
URL: https://github.com/apache/pulsar/pull/25010#discussion_r2645556542
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -4913,4 +4876,30 @@ public void readEntryFailed(ManagedLedgerException
exception, Object ctx) {
return future;
}
+
+ /**
+ * Check if the message deliver time is expired by message TTL.
+ *
+ * @param msgMetadata the message metadata
+ * @return true if the message deliver time is expired by message TTL,
false otherwise
+ */
+ protected boolean isExceedMessageTTL(MessageMetadata msgMetadata) {
+ Integer messageTTLInSeconds =
topicPolicies.getMessageTTLInSeconds().get();
+ if (messageTTLInSeconds == null || messageTTLInSeconds <= 0) {
+ return false;
+ }
Review Comment:
I think it should only be necessary to parse metadata when maxDelayLimit > 0
or TTL > 0; otherwise, return false directly.
Example:
```
if (!isDelayedDeliveryEnabled()) return false;
long maxDelay = getDelayedDeliveryMaxDelayInMillis();
Integer ttl = topicPolicies.getMessageTTLInSeconds().get();
if (maxDelay <= 0 && (ttl == null || ttl <= 0)) return false;
// then parse metadata once...
```
--
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]