RobertIndie commented on code in PR #541:
URL: https://github.com/apache/pulsar-client-cpp/pull/541#discussion_r2928886803


##########
lib/ConsumerImpl.cc:
##########
@@ -1134,6 +1135,19 @@ void ConsumerImpl::messageProcessed(Message& msg, bool 
track) {
     }
 }
 
+void ConsumerImpl::onClusterSwitching() {
+    {
+        LockGuard lock{mutex_};
+        incomingMessages_.clear();
+        startMessageId_ = startMessageIdFromConfig_;
+        lastDequedMessageId_ = MessageId::earliest();
+        lastMessageIdInBroker_ = MessageId::earliest();
+        seekStatus_ = SeekStatus::NOT_STARTED;
+        lastSeekArg_.reset();
+    }
+    ackGroupingTrackerPtr_->flushAndClean();
+}

Review Comment:
   We should also reset `HandlerBase::redirectedClusterURI_` for both producers 
and consumers when switching clusters. Otherwise, if a handler has previously 
received a topic migration command, it may still attempt to reconnect to the 
old cluster even after the cluster switch.



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