-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-3409: Improve exceptions during retry
Fixes: #3409 - During error handling, records in retry are throwing `KafkaException` after seeking that causes the exception to get logged which maybe misleading. It seems to indicate that the error handling process itself thew the exception, while the exception was thrown in order to prevent accidental committing of a not-yet recovered record. Change this exception during seeks in retry while handling error from `KafkaException` to a new framework-only used exception - `RecordInRetryException` that simply logs the message at INFO level.
- Loading branch information
1 parent
821b383
commit bcb462e
Showing
6 changed files
with
73 additions
and
19 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
spring-kafka/src/main/java/org/springframework/kafka/listener/RecordInRetryException.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,46 @@ | ||
/* | ||
* Copyright 2024-2024 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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.springframework.kafka.listener; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import org.springframework.core.NestedRuntimeException; | ||
|
||
/** | ||
* Internal {@link NestedRuntimeException} that is used as an exception thrown | ||
* when the record is in retry and not yet recovered during error handling. | ||
* This is to prevent the record from being prematurely committed in the middle of a retry. | ||
* | ||
* Intended only for framework use and thus the package-protected access. | ||
* | ||
* @author Soby Chacko | ||
* @since 3.3.0 | ||
*/ | ||
@SuppressWarnings("serial") | ||
class RecordInRetryException extends NestedRuntimeException { | ||
|
||
/** | ||
* Package protected constructor to create an instance with the provided properties. | ||
* | ||
* @param message logging message | ||
* @param cause {@link Throwable} | ||
*/ | ||
RecordInRetryException(String message, @Nullable Throwable cause) { | ||
super(message, 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
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