merlimat commented on a change in pull request #9275:
URL: https://github.com/apache/pulsar/pull/9275#discussion_r562975085



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/WorkerUtils.java
##########
@@ -343,4 +349,47 @@ public static boolean 
isFunctionCodeBuiltin(Function.FunctionDetailsOrBuilder fu
                 .startMessageId(startMessageId)
                 .create();
     }
+
+    public static Producer<byte[]> 
createExclusiveProducerWithRetry(PulsarClient client,
+                                                                    String 
topic,
+                                                                    String 
producerName) {
+        Actions.Action createProducerAction = Actions.Action.builder()
+                .actionName(String.format("Creating exclusive producer for 
topic %s", topic))
+                .numRetries(5)
+                .sleepBetweenInvocationsMs(10000)
+                .supplier(() -> {
+                    try {
+                        Producer<byte[]> producer = 
client.newProducer().topic(topic)
+                                .accessMode(ProducerAccessMode.Exclusive)

Review comment:
       Would it make sense to use `WaitForExclusive` here? So that the producer 
instance will stay pending until it becomes the leader?

##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/WorkerUtils.java
##########
@@ -343,4 +349,47 @@ public static boolean 
isFunctionCodeBuiltin(Function.FunctionDetailsOrBuilder fu
                 .startMessageId(startMessageId)
                 .create();
     }
+
+    public static Producer<byte[]> 
createExclusiveProducerWithRetry(PulsarClient client,
+                                                                    String 
topic,
+                                                                    String 
producerName) {
+        Actions.Action createProducerAction = Actions.Action.builder()
+                .actionName(String.format("Creating exclusive producer for 
topic %s", topic))
+                .numRetries(5)
+                .sleepBetweenInvocationsMs(10000)
+                .supplier(() -> {
+                    try {
+                        Producer<byte[]> producer = 
client.newProducer().topic(topic)
+                                .accessMode(ProducerAccessMode.Exclusive)
+                                .enableBatching(false)

Review comment:
       Do you remember if there was any reason for not using batching here?




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