Skip to content

Commit

Permalink
KAFKA-16448: Update ErrorHandlerContext
Browse files Browse the repository at this point in the history
Co-authored-by: Dabz <[email protected]>
Co-authored-by: sebastienviale <[email protected]>
  • Loading branch information
3 people committed May 27, 2024
1 parent ce4fbb2 commit 2acb03a
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ public interface ErrorHandlerContext {
* <p> If this method is invoked in a sub-topology due to a repartition, the returned key would be one sent
* to the repartition topic.
*
* <p> Always returns null if this method is invoked within a
* {@link org.apache.kafka.streams.errors.ProductionExceptionHandler#handle(ErrorHandlerContext, org.apache.kafka.clients.producer.ProducerRecord, Exception)}
*
* @return the raw byte of the key of the source message
*/
byte[] sourceRawKey();
Expand All @@ -116,9 +113,6 @@ public interface ErrorHandlerContext {
* <p> If this method is invoked in a sub-topology due to a repartition, the returned value would be one sent
* to the repartition topic.
*
* <p> Always returns null if this method is invoked within a
* {@link org.apache.kafka.streams.errors.ProductionExceptionHandler#handle(ErrorHandlerContext, org.apache.kafka.clients.producer.ProducerRecord, Exception)}
*
* @return the raw byte of the value of the source message
*/
byte[] sourceRawValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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.common.header.Headers;
import org.apache.kafka.streams.processor.TaskId;

public class ErrorHandlerContextImpl implements ErrorHandlerContext {
private final String topic;
private final int partition;
private final long offset;
private final Headers headers;
private final byte[] sourceRawKey;
private final byte[] sourceRawValue;
private final String processorNodeId;
private final TaskId taskId;

public ErrorHandlerContextImpl(final String topic,
final int partition,
final long offset,
final Headers headers,
final byte[] sourceRawKey,
final byte[] sourceRawValue,
final String processorNodeId,
final TaskId taskId) {
this.topic = topic;
this.partition = partition;
this.offset = offset;
this.headers = headers;
this.sourceRawKey = sourceRawKey;
this.sourceRawValue = sourceRawValue;
this.processorNodeId = processorNodeId;
this.taskId = taskId;
}


@Override
public String topic() {
return this.topic;
}

@Override
public int partition() {
return this.partition;
}

@Override
public long offset() {
return this.offset;
}

@Override
public Headers headers() {
return this.headers;
}

@Override
public byte[] sourceRawKey() {
return this.sourceRawKey;
}

@Override
public byte[] sourceRawValue() {
return this.sourceRawValue;
}

@Override
public String processorNodeId() {
return this.processorNodeId;
}

@Override
public TaskId taskId() {
return this.taskId;
}
}

0 comments on commit 2acb03a

Please sign in to comment.