DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Status
Current state: Under Discussion
Discussion thread: here
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
KIP-334 introduced into the Consumer the RecordDeserializationException with offsets information. That is useful to skip a poison pill but as you do not have access to the Record, it still prevents easy implementation of dead letter queue or simply logging the faulty data.
Public Interfaces
The change in the RecordDeserializationException would be modification of the constructor and a new method to get the ConsumerRecord.
As it’s only addition, it would still be compatible with existing consumer code.
public class RecordDeserializationException extends SerializationException {
private static final long serialVersionUID = 2L;
private final TopicPartition partition;
private final ConsumerRecord<byte[], byte[]> consumerRecord;
public RecordDeserializationException(TopicPartition partition,
ConsumerRecord<byte[], byte[]> record,
String message,
Throwable cause) {
super(message, cause);
this.partition = partition;
this.consumerRecord = record;
}
public TopicPartition topicPartition() {
return partition;
}
public long offset() {
return consumerRecord.offset();
}
public ConsumerRecord<byte[], byte[]> getConsumerRecord() {
return consumerRecord;
}
}
Proposed Changes
We propose to include the Record object to the RecordDeserializationException and provide a getConsumerRecord method that will lazily create the needed wrapper object if needed. This would still allow us to access offsets and then skip the record but also to fetch the concerned data for specific processing by sending it to a dead letter queue or whatever action that makes sense.
Compatibility, Deprecation, and Migration Plan
This change is backward compatible and will have no impact on existing application.
Test Plan
- Unit test CompletedFetchTest
Rejected Alternatives
- Using a raw byte array consumer and doing the deserialization in the user code. This permits dead letter queue implementation but is moving all the complexity of deseliarization to user’s code.