-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-16448: Add ErrorHandlerContext in production exception handler #16433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mjsax
merged 7 commits into
apache:trunk
from
sebastienviale:KAFKA-16448-Production-Add-Error-Handler-Context
Jul 30, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f367f7
KAFKA-16448 Add Error Handler Context for Production Exception Handler
sebastienviale 94242d8
KAFKA-16448 Add Error Handler Context for Production Exception Handler
sebastienviale 1fd0a66
KAFKA-16448 Add Error Handler Context for Production Exception Handler
sebastienviale 057464f
KAFKA-16448 Add Error Handler Context for Production Exception Handler
sebastienviale 1efb3b2
KAFKA-16448 Add Error Handler Context for Production Exception Handle…
sebastienviale 419155c
KAFKA-16448 Add Error Handler Context for Production Exception Handle…
sebastienviale 902ae98
KAFKA-16448 Add Error Handler Context for Production Exception Handle…
sebastienviale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,22 +30,60 @@ public interface ProductionExceptionHandler extends Configurable { | |
| * | ||
| * @param record The record that failed to produce | ||
| * @param exception The exception that occurred during production | ||
| * @deprecated Since 3.9. Use {@link #handle(ErrorHandlerContext, ProducerRecord, Exception)} instead. | ||
| */ | ||
| ProductionExceptionHandlerResponse handle(final ProducerRecord<byte[], byte[]> record, | ||
| final Exception exception); | ||
| @Deprecated | ||
| default ProductionExceptionHandlerResponse handle(final ProducerRecord<byte[], byte[]> record, | ||
| final Exception exception) { | ||
| throw new UnsupportedOperationException(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KIP says
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KIP has been updated |
||
| } | ||
|
|
||
| /** | ||
| * Inspect a record that we attempted to produce, and the exception that resulted | ||
| * from attempting to produce it and determine whether or not to continue processing. | ||
| * | ||
| * @param context The error handler context metadata | ||
| * @param record The record that failed to produce | ||
| * @param exception The exception that occurred during production | ||
| */ | ||
| @SuppressWarnings("deprecation") | ||
| default ProductionExceptionHandlerResponse handle(final ErrorHandlerContext context, | ||
| final ProducerRecord<byte[], byte[]> record, | ||
| final Exception exception) { | ||
| return handle(record, exception); | ||
| } | ||
|
|
||
| /** | ||
| * Handles serialization exception and determine if the process should continue. The default implementation is to | ||
| * fail the process. | ||
| * | ||
| * @param record the record that failed to serialize | ||
| * @param exception the exception that occurred during serialization | ||
| * @deprecated Since 3.9. Use {@link #handle(ErrorHandlerContext, ProducerRecord, Exception)} instead. | ||
| */ | ||
| @Deprecated | ||
| default ProductionExceptionHandlerResponse handleSerializationException(final ProducerRecord record, | ||
| final Exception exception) { | ||
| return ProductionExceptionHandlerResponse.FAIL; | ||
| } | ||
|
|
||
| /** | ||
| * Handles serialization exception and determine if the process should continue. The default implementation is to | ||
| * fail the process. | ||
| * | ||
| * @param context the error handler context metadata | ||
| * @param record the record that failed to serialize | ||
| * @param exception the exception that occurred during serialization | ||
| * @param origin the origin of the serialization exception | ||
| */ | ||
| @SuppressWarnings("deprecation") | ||
| default ProductionExceptionHandlerResponse handleSerializationException(final ErrorHandlerContext context, | ||
| final ProducerRecord record, | ||
| final Exception exception, | ||
| final SerializationExceptionOrigin origin) { | ||
| return handleSerializationException(record, exception); | ||
| } | ||
|
|
||
| enum ProductionExceptionHandlerResponse { | ||
| /* continue processing */ | ||
| CONTINUE(0, "CONTINUE"), | ||
|
|
@@ -68,4 +106,11 @@ enum ProductionExceptionHandlerResponse { | |
| this.name = name; | ||
| } | ||
| } | ||
|
|
||
| enum SerializationExceptionOrigin { | ||
| /* serialization exception occurred during serialization of the key */ | ||
| KEY, | ||
| /* serialization exception occurred during serialization of the value */ | ||
| VALUE | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we can modify this without deprecating the old method and mentioning it in the KIP since it is part of the public API.
I am aware that this method is only called internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we did it for the deserialization exception handler implementations. I'm wondering why we did not do the same for the production.. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cadonna I updated KIP-1033 with a word regarding deserialization and production handler implementations