lhotari commented on code in PR #24020:
URL: https://github.com/apache/pulsar/pull/24020#discussion_r1977043250


##########
pip/pip-409.md:
##########
@@ -33,25 +33,88 @@ retry/dead letter topic.
 
 ## Design & Implementation Details
 
-- Add two new configurations in `DeadLetterPolicy`:
+- Add `ProducerBuilderContext` and `ProducerBuilderCustomizer` interface:
+```java
+public interface ProducerBuilderContext {
+    /**
+     * Returns the default name of topic for the dead letter or retry letter 
producer. This topic name is used
+     * unless the ProducerBuilderCustomizer overrides it.
+     *
+     * @return a {@code String} representing the input topic name
+     */
+    String getDefaultTopicName();
+
+    /**
+     * Returns the name of the input topic for which the dead letter or retry 
letter producer is being configured.
+     *
+     * @return a {@code String} representing the input topic name
+     */
+    String getInputTopicName();
+
+    /**
+     * Returns the name of the subscription for which the dead letter or retry 
letter producer is being configured.
+     *
+     * @return a {@code String} representing the subscription name
+     */
+    String getInputTopicSubscriptionName();
+}
+
+public interface ProducerBuilderCustomizer {
+    /**
+     * Customize the given producer builder with settings specific to the 
topic context provided.
+     *
+     * @param context         the context containing information about the 
input topic and the subscription
+     * @param producerBuilder the producer builder instance to be customized
+     */
+    void customize(ProducerBuilderContext context, ProducerBuilder<byte[]> 
producerBuilder);

Review Comment:
   > I agree. The purpose of introducing interface `ProducerBuilderCustomizer` 
is to retrict the creation of `ProducerBuilder`. 
   
   If there's a need to restrict the creation, the return type should be `void` 
in that case. However, wouldn't it be a valid use case to use a different 
Pulsar client instance for the producer? In that case allowing to return a 
different instance should be made possible.
   
   
   > If we allow returning a different producer builder created by user, there 
is no need for `ProducerBuilderCustomizer`.
   > 
   
   That's not the case. A user might want to rely on the defaults for all other 
setting than what they are overriding in the customizer.



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