gaoran10 commented on a change in pull request #14870:
URL: https://github.com/apache/pulsar/pull/14870#discussion_r835706515



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerCloseTest.java
##########
@@ -99,6 +103,25 @@ public void 
testProducerCloseFailsPendingBatchWhenPreviousStateNotReadyCallback(
         }
     }
 
+    @Test(timeOut = 10_000)
+    public void brokerCloseTest() throws Exception {
+        initClient();
+
+        String topic = "broker-close-test-" + 
RandomStringUtils.randomAlphabetic(5);
+        @Cleanup
+        ProducerImpl<byte[]> producer = (ProducerImpl<byte[]>) 
pulsarClient.newProducer()
+                .topic(topic)
+                .create();
+        producer.newMessage().value("test".getBytes()).send();
+
+        Optional<Topic> topicOptional = pulsar.getBrokerService()
+                
.getTopicReference(TopicName.get(topic).getPartitionedTopicName());
+        Assert.assertTrue(topicOptional.isPresent());
+        topicOptional.get().close(true).get();
+        Assert.assertEquals(producer.getState(), 
HandlerState.State.Connecting);

Review comment:
       I'll new a long backoff client to make the producer connection don't 
re-connect immediately, we can find this log, the connection will try again in 
5.0 s.
   
   ```
   2022-03-26T11:21:44,782+0800 [pulsar-client-io-44-1] INFO  
org.apache.pulsar.client.impl.ConnectionHandler - [broker-close-test-qAAkx] 
[test-0-0] Closed connection [id: 0x07f473b5, L:/127.0.0.1:49280 - 
R:localhost/127.0.0.1:49272] -- Will try again in 5.0 s
   ```




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