Rajarshi-Misra commented on code in PR #21606:
URL: https://github.com/apache/kafka/pull/21606#discussion_r2936350529


##########
docs/streams/developer-guide/config-streams.md:
##########
@@ -1485,6 +1485,57 @@ Serde for the inner class of a windowed record. Must 
implement the `Serde` inter
 >         }
 >     }
 
+>**Note: The example above demonstrates manual production to a DLQ topic. The 
following example shows the recommended approach using the built-in DLQ 
support.**
+> A custom processing exception handler can decide whether to continue or fail 
processing when user logic throws an exception. If DLQ behavior is required, 
return DLQ records from the handler response.
+>
+> **Custom Exception Handler Implementation**
+>
+> The following example forwards failed records to a configured DLQ topic:
+>
+> ```java
+> public class DlqProcessingExceptionHandler implements 
ProcessingExceptionHandler {
+>
+>     private String deadLetterQueueTopic;
+>
+>     @Override
+>     public Response handleError(final ErrorHandlerContext context,
+>                                 final Record<?, ?> record,
+>                                 final Exception exception) {
+>
+>         return Response.resume(
+>             ExceptionHandlerUtils.maybeBuildDeadLetterQueueRecords(
+>                 deadLetterQueueTopic,
+>                 context.sourceRawKey(),
+>                 context.sourceRawValue(),
+>                 context,
+>                 exception
+>             )
+>         );
+>     }
+>
+>     @Override
+>     public void configure(final Map<String, ?> configs) {
+>         deadLetterQueueTopic = (String) configs.get(
+>             StreamsConfig.ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_CONFIG
+>         );
+>     }
+> }
+> ```
+> To enable the custom exception handler and configure the DLQ topic:
+>
+> ```java
+> Properties props = new Properties();
+>
+> props.put(
+>     StreamsConfig.PROCESSING_EXCEPTION_HANDLER_CLASS_CONFIG,
+>     DlqProcessingExceptionHandler.class
+> );
+>
+> props.put(
+>     StreamsConfig.ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_CONFIG,

Review Comment:
   I have made it optional



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