equanz commented on a change in pull request #10279:
URL: https://github.com/apache/pulsar/pull/10279#discussion_r620971771



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PartitionedProducerImpl.java
##########
@@ -169,6 +186,30 @@ private void start() {
 
     @Override
     CompletableFuture<MessageId> internalSendWithTxnAsync(Message<?> message, 
Transaction txn) {
+        int partition = routerPolicy.choosePartition(message, topicMetadata);
+        checkArgument(partition >= 0 && partition < 
topicMetadata.numPartitions(),
+                "Illegal partition index chosen by the message routing policy: 
" + partition);
+
+        if (!producers.containsKey(partition)) {
+            final State createState = createProducer(partition).handle((prod, 
createException) -> {
+                if (createException != null) {
+                    log.error("[{}] Could not create internal producer. 
partitionIndex: {}", topic, partition,
+                            createException);
+                    try {
+                        producers.remove(partition).close();

Review comment:
       The  reason for it is to recreate internal producer when producer 
creation is failed. This behavior is tested 
[here](https://github.com/apache/pulsar/blob/d49aab48119cb31ab7935abbd38f117ef89cdfc7/pulsar-broker/src/test/java/org/apache/pulsar/client/api/ClientErrorsTest.java#L493-L546).
   




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to