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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -84,6 +85,11 @@ public boolean isAutoSkipNonRecoverableData() {
                 && 
this.cursor.getManagedLedger().getConfig().isAutoSkipNonRecoverableData();
     }
 
+    @Override
+    public CompletableFuture<Boolean> expireMessagesAsync(int 
messageTTLInSeconds) {
+        return 
CompletableFuture.completedFuture(expireMessages(messageTTLInSeconds));

Review Comment:
   `expireMessages` is a blocking implementation.
   This could be made to run asynchronously in a separate thread (Executor) 
with `CompletableFuture.supplyAsync` without having to rewrite the existing 
blocking implementation.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java:
##########
@@ -1236,6 +1236,25 @@ public boolean expireMessages(int messageTTLInSeconds) {
         return expiryMonitor.expireMessages(messageTTLInSeconds);
     }
 
+    @Override
+    public CompletableFuture<Boolean> expireMessagesAsync(int 
messageTTLInSeconds) {
+        long backlog = getNumberOfEntriesInBacklog(false);
+        if (backlog == 0) {
+            return CompletableFuture.completedFuture(false);
+        }
+        if (dispatcher != null && dispatcher.isConsumerConnected() && backlog 
< MINIMUM_BACKLOG_FOR_EXPIRY_CHECK) {
+            return topic.isOldestMessageExpiredAsync(cursor, 
messageTTLInSeconds).thenCompose(bool -> {
+                if (bool) {

Review Comment:
   use a proper variable name instead of `bool`. For example `oldestMsgExpired`.



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