liangyepianzhou commented on code in PR #21183:
URL: https://github.com/apache/pulsar/pull/21183#discussion_r1369450260


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java:
##########
@@ -166,7 +166,20 @@ public synchronized CompletableFuture<Void> 
addConsumer(Consumer consumer) {
         }
 
         if (subscriptionType == SubType.Exclusive && !consumers.isEmpty()) {
-            return FutureUtil.failedFuture(new 
ConsumerBusyException("Exclusive consumer is already connected"));
+            Consumer actConsumer = ACTIVE_CONSUMER_UPDATER.get(this);
+            if (actConsumer != null) {
+                return 
actConsumer.cnx().checkConnectionLiveness().thenCompose(actConsumerStillAlive 
-> {
+                    if (actConsumerStillAlive == null || 
actConsumerStillAlive) {
+                        return FutureUtil.failedFuture(new 
ConsumerBusyException("Exclusive consumer is already"
+                                + " connected"));
+                    } else {
+                        return addConsumer(consumer);
+                    }
+                });
+            } else {
+                // It should never happen.
+                return FutureUtil.failedFuture(new 
ConsumerBusyException("Active consumer is in a strange state."));

Review Comment:
   ```suggestion
                   return FutureUtil.failedFuture(new 
ConsumerBusyException("Active consumer is in a strange state."));
                   return FutureUtil.failedFuture(new 
ConsumerBusyException("Failed to acquire active consumer for exclusive 
consumer. Consumers size: " + consumers.size()));                
                   
   ```



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