cadonna commented on code in PR #17942:
URL: https://github.com/apache/kafka/pull/17942#discussion_r1860617270
##########
streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java:
##########
@@ -588,6 +588,10 @@ public class StreamsConfig extends AbstractConfig {
public static final String ENABLE_METRICS_PUSH_DOC = "Whether to enable
pushing of internal client metrics for (main, restore, and global) consumers,
producers, and admin clients." +
" The cluster must have a client metrics subscription which
corresponds to a client.";
+ public static final String ERRORS_DEAD_LETTER_QUEUE_TOPIC_NAME_CONFIG =
"errors.dead.letter.queue.topic.name";
Review Comment:
Could you please add unit tests?
##########
streams/src/main/java/org/apache/kafka/streams/errors/CommonExceptionHandler.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.streams.errors;
+
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.Configurable;
+import org.apache.kafka.common.errors.InvalidConfigurationException;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.apache.kafka.streams.StreamsConfig;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * {@code CommonExceptionHandler} Contains utilities method that could be used
by all exception handlers
+ */
+public class CommonExceptionHandler implements Configurable {
+ protected String deadLetterQueueTopicName = null;
+ public static final String HEADER_ERRORS_EXCEPTION_NAME =
"__streams.errors.exception";
+ public static final String HEADER_ERRORS_STACKTRACE_NAME =
"__streams.errors.stacktrace";
+ public static final String HEADER_ERRORS_EXCEPTION_MESSAGE_NAME =
"__streams.errors.message";
+ public static final String HEADER_ERRORS_TOPIC_NAME =
"__streams.errors.topic";
+ public static final String HEADER_ERRORS_PARTITION_NAME =
"__streams.errors.partition";
+ public static final String HEADER_ERRORS_OFFSET_NAME =
"__streams.errors.offset";
+
+
+ public boolean shouldBuildDeadLetterQueueRecord() {
Review Comment:
Why is this public? It is only used within this class.
##########
streams/src/main/java/org/apache/kafka/streams/errors/CommonExceptionHandler.java:
##########
Review Comment:
You cannot add a class to the public API that was not mentioned in the KIP.
##########
streams/src/main/java/org/apache/kafka/streams/errors/DeserializationExceptionHandler.java:
##########
@@ -89,10 +95,35 @@ enum DeserializationHandlerResponse {
*/
public final int id;
+ /** a list of Kafka records to publish, e.g. in a Dead Letter Queue
topic */
+ private final Queue<ProducerRecord<byte[], byte[]>>
deadLetterQueueRecordsQueue;
+
DeserializationHandlerResponse(final int id, final String name) {
this.id = id;
this.name = name;
+ this.deadLetterQueueRecordsQueue = new ConcurrentLinkedQueue<>();
}
- }
+ public DeserializationHandlerResponse andAddToDeadLetterQueue(final
Iterable<org.apache.kafka.clients.producer.ProducerRecord<byte[], byte[]>>
deadLetterQueueRecords) {
+ if (deadLetterQueueRecords == null) {
+ return this;
+ }
+ for (final ProducerRecord<byte[], byte[]> deadLetterQueueRecord :
deadLetterQueueRecords) {
+ this.deadLetterQueueRecordsQueue.add(deadLetterQueueRecord);
+ }
+ return this;
+ }
+
+ public List<ProducerRecord<byte[], byte[]>>
drainDeadLetterQueueRecords() {
Review Comment:
According to the KIP this should be named `deadLetterQueueReords()`.
##########
streams/src/main/java/org/apache/kafka/streams/errors/CommonExceptionHandler.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.streams.errors;
+
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.Configurable;
+import org.apache.kafka.common.errors.InvalidConfigurationException;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.apache.kafka.streams.StreamsConfig;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * {@code CommonExceptionHandler} Contains utilities method that could be used
by all exception handlers
+ */
+public class CommonExceptionHandler implements Configurable {
Review Comment:
It would be better to define this class as a immutable utility class in the
internal package that provides some utility methods to the default exception
handlers. That means, no inheritance.
--
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]