dragosvictor commented on code in PR #21682:
URL: https://github.com/apache/pulsar/pull/21682#discussion_r1424854587


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java:
##########
@@ -835,16 +835,44 @@ protected void handleCloseProducer(CommandCloseProducer 
closeProducer) {
 
     @Override
     protected void handleCloseConsumer(CommandCloseConsumer closeConsumer) {
-        log.info("[{}] Broker notification of Closed consumer: {}", 
remoteAddress, closeConsumer.getConsumerId());
+        log.info("[{}] Broker notification of Closed consumer: {}, 
assignedBrokerUrl: {}, assignedBrokerUrlTls: {}",
+                remoteAddress, closeConsumer.getConsumerId(),
+                closeConsumer.hasAssignedBrokerServiceUrl() ? 
closeConsumer.getAssignedBrokerServiceUrl() : null,
+                closeConsumer.hasAssignedBrokerServiceUrlTls() ? 
closeConsumer.getAssignedBrokerServiceUrlTls() : null);
         final long consumerId = closeConsumer.getConsumerId();
         ConsumerImpl<?> consumer = consumers.remove(consumerId);
         if (consumer != null) {
-            consumer.connectionClosed(this);
+            String brokerServiceUrl = getBrokerServiceUrl(closeConsumer, 
consumer);
+            Optional<URI> hostUri = parseUri(brokerServiceUrl, 
closeConsumer.getRequestId());
+            Optional<Long> initialConnectionDelayMs = hostUri.map(__ -> 0L);
+            consumer.connectionClosed(this, initialConnectionDelayMs, hostUri);
         } else {
             log.warn("Consumer with id {} not found while closing consumer ", 
consumerId);
         }
     }
 
+    private static String getBrokerServiceUrl(CommandCloseConsumer 
closeConsumer, ConsumerImpl<?> consumer) {
+        if (consumer.getClient().getConfiguration().isUseTls()) {
+            if (closeConsumer.hasAssignedBrokerServiceUrlTls()) {
+                return closeConsumer.getAssignedBrokerServiceUrlTls();
+            }
+        } else if (closeConsumer.hasAssignedBrokerServiceUrl()) {
+            return closeConsumer.getAssignedBrokerServiceUrl();
+        }
+        return null;
+    }
+
+    private Optional<URI> parseUri(String url, long requestId) {

Review Comment:
   Thanks for suggesting! Fixed.



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