You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/27 13:38:35 UTC

[GitHub] [pulsar-client-cpp] shibd commented on a diff in pull request #71: [feat] Support expiration for chunked messages

shibd commented on code in PR #71:
URL: https://github.com/apache/pulsar-client-cpp/pull/71#discussion_r1006850483


##########
lib/ConsumerImpl.cc:
##########
@@ -319,6 +320,27 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback originalCallback) {
     }
 }
 
+void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
+    checkExpiredChunkedTimer_ = executor_->createDeadlineTimer();

Review Comment:
   If `checkExpiredChunkedTimer_`  already existed, not need to recreate it.



##########
lib/ConsumerImpl.cc:
##########
@@ -319,6 +320,27 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback originalCallback) {
     }
 }
 
+void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
+    checkExpiredChunkedTimer_ = executor_->createDeadlineTimer();
+    checkExpiredChunkedTimer_->expires_from_now(
+        boost::posix_time::milliseconds(expireTimeOfIncompleteChunkedMessageMs_));
+    checkExpiredChunkedTimer_->async_wait([this](const boost::system::error_code& ec) -> void {
+        if (ec) {
+            LOG_DEBUG(getName() << " Check expired chunked messages was failed or cancelled, code[" << ec
+                                << "].");
+            return;
+        }
+        Lock lock(chunkProcessMutex_);
+        long currentTimeMs = TimeUtils::currentTimeMillis();
+        chunkedMessageCache_.removeOldestValuesIf(
+            [this, &currentTimeMs](const std::string& uuid, const ChunkedMessageCtx& ctx) -> bool {

Review Comment:
   Just capture `expireTimeOfIncompleteChunkedMessageMs_ ` on here.



##########
lib/ConsumerImpl.h:
##########
@@ -33,8 +33,11 @@
 #include "NegativeAcksTracker.h"
 #include "Synchronized.h"
 #include "TestUtil.h"
+#include "TimeUtils.h"
 #include "UnboundedBlockingQueue.h"
 
+using namespace pulsar;

Review Comment:
   There is no need to declare using pulsar namespace here because the class is already in this namespace



##########
lib/ConsumerImpl.cc:
##########
@@ -319,6 +320,27 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback originalCallback) {
     }
 }
 
+void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
+    checkExpiredChunkedTimer_ = executor_->createDeadlineTimer();
+    checkExpiredChunkedTimer_->expires_from_now(
+        boost::posix_time::milliseconds(expireTimeOfIncompleteChunkedMessageMs_));
+    checkExpiredChunkedTimer_->async_wait([this](const boost::system::error_code& ec) -> void {

Review Comment:
   Need to capture `smart pointers` to prevent segmentation faults. Weak pointers are recommended to prevent circular references.
   https://github.com/apache/pulsar/pull/17481



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org