michaeljmarshall commented on a change in pull request #14458:
URL: https://github.com/apache/pulsar/pull/14458#discussion_r815188558



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1273,6 +1273,20 @@ protected void handleProducer(final CommandProducer 
cmdProducer) {
                             if (!Strings.isNullOrEmpty(initialSubscriptionName)
                                     && topic.isPersistent()
                                     && 
!topic.getSubscriptions().containsKey(initialSubscriptionName)) {
+                                if 
(!this.getBrokerService().isAllowAutoSubscriptionCreation(topicName)) {
+                                    String msg =
+                                            "Could not create the initial 
subscription due to the auto subscription "
+                                                    + "creation is not 
allowed.";
+                                    if (producerFuture.completeExceptionally(
+                                            new 
BrokerServiceException.NotAllowedException(msg))) {
+                                        log.warn("[{}] {} 
initialSubscriptionName: {}, topic: {}",
+                                                remoteAddress, msg, 
initialSubscriptionName, topicName);
+                                        
commandSender.sendErrorResponse(requestId,
+                                                ServerError.NotAllowedError, 
msg);

Review comment:
       Note that the consequence of sending this `NotAllowedError` is that the 
consumer will indefinitely send messages back to the broker to be redelivered. 
I think this is a sane default since it means messages won't be lost. I just 
want to make sure we agree on this design.

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBuilderImpl.java
##########
@@ -328,7 +328,9 @@ private ProducerBuilderImpl(PulsarClientImpl client, 
ProducerConfigurationData c
     /**
      * Use this config to automatically create an initial subscription when 
creating the topic.
      * If this field is not set, the initial subscription will not be created.
-     * This method is limited to internal use
+     * If this field is set but the broker's `allowAutoSubscriptionCreation` 
is disabled, the producer will fail to
+     * be created.
+     * This method is limited to internal use.

Review comment:
       Nit: it could be helpful to explain to end users when this method is 
used, since the method itself isn't limited to internal use.




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