Skip to content

Commit 0a3925a

Browse files
committed
spring-projectsGH-615: Docs - Migrating Legacy Error Handlers
See spring-projects#615
1 parent 9f48d00 commit 0a3925a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

spring-kafka-docs/src/main/asciidoc/kafka.adoc

+17-1
Original file line numberDiff line numberDiff line change
@@ -5058,6 +5058,8 @@ These error handlers can handle errors for both record and batch listeners, allo
50585058
`CommonErrorHandler` implementations to replace most legacy framework error handler implementations are provided and the legacy error handlers deprecated.
50595059
The legacy interfaces are still supported by listener containers and listener container factories; they will be deprecated in a future release.
50605060

5061+
See <<migrating-legacy-eh>> for information to convert custom error handlers to `CommonErrorHandler`.
5062+
50615063
When transactions are being used, no error handlers are configured, by default, so that the exception will roll back the transaction.
50625064
Error handling for transactional containers are handled by the <<after-rollback,`AfterRollbackProcessor`>>.
50635065
If you provide a custom error handler when using transactions, it must throw an exception if you want the transaction rolled back.
@@ -5267,7 +5269,7 @@ By default, the exception type is not considered.
52675269
Also see <<delivery-header>>.
52685270

52695271
[[batch-listener-conv-errors]]
5270-
===== Conversion Errors with Batch Error Handlers
5272+
====== Conversion Errors with Batch Error Handlers
52715273

52725274
Starting with version 2.8, batch listeners can now properly handle conversion errors, when using a `MessageConverter` with a `ByteArrayDeserializer`, a `BytesDeserializer` or a `StringDeserializer`, as well as a `DefaultErrorHandler`.
52735275
When a conversion error occurs, the payload is set to null and a deserialization exception is added to the record headers, similar to the `ErrorHandlingDeserializer`.
@@ -5384,6 +5386,20 @@ If you wish to use a different error handling strategy for record and batch list
53845386
|No replacements - use `DefaultErrorHandler` and throw an exception other than `BatchListenerFailedException`.
53855387
|===
53865388

5389+
[[migrating-legacy-eh]]
5390+
====== Migrating Custom Legacy Error Handler Implementations to `CommonErrorHandler`
5391+
5392+
Refer to the javadocs in `CommonErrorHandler`.
5393+
5394+
To replace an `ErrorHandler` or `ConsumerAwareErrorHandler` implementation, you should implement `handleRecord()` and leave `remainingRecords()` to return `false` (default).
5395+
You should also implement `handleOtherException()` - to handle exceptions that occur outside the scope of record processing (e.g. consumer errors).
5396+
5397+
To replace a `RemainingRecordsErrorHandler` implementation, you should implement `handleRemaining()` and override `remainingRecords()` to return `true`.
5398+
You should also implement `handleOtherException()` - to handle exceptions that occur outside the scope of record processing (e.g. consumer errors).
5399+
5400+
To replace any `BatchErrorHandler` implementation, you should implement `handleBatch()`
5401+
You should also implement `handleOtherException()` - to handle exceptions that occur outside the scope of record processing (e.g. consumer errors).
5402+
53875403
[[after-rollback]]
53885404
===== After-rollback Processor
53895405

spring-kafka-docs/src/main/asciidoc/whats-new.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ See <<kafka-template-receive>> for more information.
5454
==== `CommonErrorHandler` Added
5555

5656
The legacy `GenericErrorHandler` and its sub-interface hierarchies for record an batch listeners have been replaced by a new single interface `CommonErrorHandler` with implementations corresponding to most legacy implementations of `GenericErrorHandler`.
57-
See <<error-handlers>> for more information.
57+
See <<error-handlers>> and <<migrating-legacy-eh>> for more information.
5858

5959
[[x28-lcc]]
6060
==== Listener Container Changes
@@ -92,4 +92,4 @@ You can now use blocking and non-blocking retries in conjunction.
9292
See <<retry-topic-combine-blocking>> for more information.
9393

9494
The KafkaBackOffException thrown when using the retryable topics feature is now logged at DEBUG level.
95-
See <<change-kboe-logging-level>> if you need to change the logging level back to WARN or set it to any other level.
95+
See <<change-kboe-logging-level>> if you need to change the logging level back to WARN or set it to any other level.

0 commit comments

Comments
 (0)