-
Notifications
You must be signed in to change notification settings - Fork 137
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
feature: #242 Explicit terminal and retry exceptions for cleaner logging and poison pills #291
Closed
Closed
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1a18281
START: Explicit retry exception for cleaner logging
astubbs 6af5beb
switch tests to utilise
astubbs 3d704c3
Merge branch 'master' into features/retry-exception
ifeeneyconfluent 7f1cd22
alternative handling flow
astubbs a3331e5
use Slf4j alpha 7 for dynamic log level - check what else is new in 2
astubbs 33454ad
Merge remote-tracking branch 'antony/features/retry-exception' into f…
astubbs 4d2eaa1
wording
astubbs 28dd391
step
astubbs 1c37ebf
step
astubbs 8a62163
Merge remote-tracking branch 'confluent/master' into features/retry-e…
astubbs 5b2b515
step
astubbs a9ded2d
terminal exception and handling
astubbs 1a72f3c
handle terminal
astubbs fb862d6
introduce Offsets class
astubbs 1f662d9
step
astubbs 830717a
step
astubbs e778a09
test and batch drafting
astubbs 7d56bad
test and batch drafting
astubbs eb42645
test and batch drafting
astubbs 8a8a780
test and batch drafting
astubbs 486caa5
Merge remote-tracking branch 'origin/master' into features/retry-exce…
astubbs 93324d0
revert partial batch failure
astubbs 14aad84
review
astubbs 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
38 changes: 38 additions & 0 deletions
38
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/Offsets.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2022 Confluent, Inc. | ||
*/ | ||
|
||
import lombok.ToString; | ||
import lombok.experimental.Delegate; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@ToString | ||
public class Offsets { | ||
|
||
@Delegate | ||
private final List<Long> rawOffsets; | ||
|
||
public Offsets(List<Long> records) { | ||
this.rawOffsets = records; | ||
} | ||
|
||
public static Offsets from(List<RecordContext<?, ?>> records) { | ||
return of(records.stream() | ||
.map(RecordContext::offset) | ||
.collect(Collectors.toUnmodifiableList())); | ||
} | ||
|
||
// due to type erasure, can't use method overloading | ||
public static Offsets of(List<Long> rawOffsetsIn) { | ||
return new Offsets(rawOffsetsIn); | ||
} | ||
|
||
public static Offsets of(long... rawOffsetsIn) { | ||
return new Offsets(Arrays.stream(rawOffsetsIn).boxed().collect(Collectors.toList())); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/PCRetriableException.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2022 Confluent, Inc. | ||
*/ | ||
|
||
import lombok.ToString; | ||
|
||
/** | ||
* A user's processing function can throw this exception, which signals to PC that processing of the message has failed, | ||
* and that it should be retired at a later time. | ||
* <p> | ||
* The advantage of throwing this exception explicitly, is that PC will not log an ERROR. If any other type of exception | ||
* is thrown by the user's function, that will be logged as an error (but will still be retried later). | ||
* <p> | ||
* So in short, if this exception is thrown, nothing will be logged (except at DEBUG level), any other exception will be | ||
* logged as an error. | ||
*/ | ||
@ToString | ||
public class PCRetriableException extends PCUserException { | ||
|
||
public PCRetriableException(String message) { | ||
super(message); | ||
} | ||
|
||
public PCRetriableException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public PCRetriableException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/PCTerminalException.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2022 Confluent, Inc. | ||
*/ | ||
|
||
/** | ||
* A user's processing function can throw this exception, which signals to PC that processing of the message has failed, | ||
* and that it should be retired at a later time. | ||
* <p> | ||
* The advantage of throwing this exception explicitly, is that PC will not log an ERROR. If any other type of exception | ||
* is thrown by the user's function, that will be logged as an error (but will still be retried later). | ||
* <p> | ||
* So in short, if this exception is thrown, nothing will be logged (except at DEBUG level), any other exception will be | ||
* logged as an error. | ||
*/ | ||
public class PCTerminalException extends PCUserException { | ||
public PCTerminalException(String message) { | ||
super(message); | ||
} | ||
|
||
public PCTerminalException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public PCTerminalException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/PCUserException.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2022 Confluent, Inc. | ||
*/ | ||
|
||
/** | ||
* todo | ||
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. docs |
||
*/ | ||
public class PCUserException extends RuntimeException { | ||
public PCUserException(String message) { | ||
super(message); | ||
} | ||
|
||
public PCUserException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public PCUserException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
This file contains 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 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.
update java doc