poorbarcode commented on code in PR #23721:
URL: https://github.com/apache/pulsar/pull/23721#discussion_r1883122450


##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ClientCnxTest.java:
##########
@@ -173,11 +188,47 @@ public void testCnxReceiveSendError() throws Exception {
         // producer also can send message
         producerOne.send("test");
         producerTwo.send("test");
+        producerThree.send("test");
         producerTwo.close();
         producerOne.close();
+        producerThree.close();
         client.close();
     }
 
+    @Test
+    public void testCnxReceiveSendErrorWithConfigMultiPerConnection() throws 
Exception {
+        PulsarClient client = 
PulsarClient.builder().serviceUrl(lookupUrl.toString())
+                .connectionsPerBroker(1000).build();
+
+        // Create a producer with customized name.
+        final String tp = BrokerTestUtil.newUniqueName(NAMESPACE + "/tp");
+        admin.topics().createNonPartitionedTopic(tp);
+        Producer<String> p = 
client.newProducer(Schema.STRING).producerName("p1").topic(tp).create();
+
+        // Inject a persistence error.
+        org.apache.pulsar.broker.service.Producer serverProducer = 
pulsar.getBrokerService().getTopic(tp, false)
+                .join().get().getProducers().values().iterator().next();
+        ServerCnx serverCnx = (ServerCnx) serverProducer.getCnx();
+        
serverCnx.getCommandSender().sendSendError(serverProducer.getProducerId(), 1/* 
sequenceId */,
+                ServerError.PersistenceError, "mocked error");
+        // Wait for the client receives the error.
+        Thread.sleep(1000);

Review Comment:
   I added Ping-Pong twice to confirm the client has handled the Error we sent
   
   ```
   // Wait for the client to receive the error.
   // If the client confirmed two Pings, it means the client has handled the 
PersistenceError we sent.
   serverCnx.checkConnectionLiveness().join();
   serverCnx.checkConnectionLiveness().join();
   ```



##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ClientCnxTest.java:
##########
@@ -173,11 +188,47 @@ public void testCnxReceiveSendError() throws Exception {
         // producer also can send message
         producerOne.send("test");
         producerTwo.send("test");
+        producerThree.send("test");
         producerTwo.close();
         producerOne.close();
+        producerThree.close();
         client.close();
     }
 
+    @Test
+    public void testCnxReceiveSendErrorWithConfigMultiPerConnection() throws 
Exception {
+        PulsarClient client = 
PulsarClient.builder().serviceUrl(lookupUrl.toString())
+                .connectionsPerBroker(1000).build();
+
+        // Create a producer with customized name.
+        final String tp = BrokerTestUtil.newUniqueName(NAMESPACE + "/tp");
+        admin.topics().createNonPartitionedTopic(tp);
+        Producer<String> p = 
client.newProducer(Schema.STRING).producerName("p1").topic(tp).create();
+
+        // Inject a persistence error.
+        org.apache.pulsar.broker.service.Producer serverProducer = 
pulsar.getBrokerService().getTopic(tp, false)
+                .join().get().getProducers().values().iterator().next();
+        ServerCnx serverCnx = (ServerCnx) serverProducer.getCnx();
+        
serverCnx.getCommandSender().sendSendError(serverProducer.getProducerId(), 1/* 
sequenceId */,
+                ServerError.PersistenceError, "mocked error");
+        // Wait for the client receives the error.
+        Thread.sleep(1000);

Review Comment:
   I added Ping-Pong twice to confirm the client has handled the Error we sent
   
   ```java
   // Wait for the client to receive the error.
   // If the client confirmed two Pings, it means the client has handled the 
PersistenceError we sent.
   serverCnx.checkConnectionLiveness().join();
   serverCnx.checkConnectionLiveness().join();
   ```



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