Class AbstractRecoveringExceptionHandler<R>
java.lang.Object
org.springframework.kafka.streams.AbstractRecoveringExceptionHandler<R>
- Type Parameters:
R- the handler-specific response type
- Direct Known Subclasses:
RecoveringDeserializationExceptionHandler,RecoveringProcessingExceptionHandler,RecoveringProductionExceptionHandler
Abstract base class for recovering Kafka Streams exception handlers.
- Since:
- 4.1
- Author:
- Loïc Greffier
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DeadLetterRecordManagerprotected @Nullable Stringprotected @Nullable KafkaStreamsDeadLetterDestinationResolverprotected @Nullable ConsumerRecordRecoverer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureCommon(Map<String, ?> configs, String destinationResolverKey, String recovererKey, @Nullable String legacyRecovererKey) Configure common attributes.protected abstract Rfail()Create a response indicating that processing should fail.protected RhandleErrorCommon(org.apache.kafka.streams.errors.ErrorHandlerContext context, org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> record, Exception exception) Handles errors using a prioritized recovery strategy.protected abstract RCreate a response indicating that processing should resume.
-
Field Details
-
deadLetterRecordManager
-
recoverer
-
destinationResolver
-
deadLetterTopic
-
-
Constructor Details
-
AbstractRecoveringExceptionHandler
protected AbstractRecoveringExceptionHandler() -
AbstractRecoveringExceptionHandler
-
-
Method Details
-
handleErrorCommon
protected R handleErrorCommon(org.apache.kafka.streams.errors.ErrorHandlerContext context, org.apache.kafka.clients.consumer.ConsumerRecord<?, ?> record, Exception exception) Handles errors using a prioritized recovery strategy.- Resume the stream by forwarding to the topic-partition resolved by
KafkaStreamsDeadLetterDestinationResolvervia the native Kafka Streams DLQ. - Resume the stream by forwarding to the
errors.dead.letter.queue.topic.nametopic via the native Kafka Streams DLQ. - Delegate the recovery logic and dead-letter record sending to the
ConsumerRecordRecoverer. Resume with no dead-letter records, as it is expected to be handled by theConsumerRecordRecoverer. - Fail the stream with no dead-letter records.
- Parameters:
context- the error handler contextrecord- the consumer record that caused the errorexception- the exception that occurred- Returns:
- a handler-specific response
- Resume the stream by forwarding to the topic-partition resolved by
-
configureCommon
protected void configureCommon(Map<String, ?> configs, String destinationResolverKey, String recovererKey, @Nullable String legacyRecovererKey) Configure common attributes.- Parameters:
configs- the configuration mapdestinationResolverKey- the property key for the native DLQ destination resolverrecovererKey- the property key for the recovererlegacyRecovererKey- the legacy property key for the recoverer, used as fallback if recovererKey is not defined
-
fail
Create a response indicating that processing should fail.- Returns:
- a handler-specific fail response
-
resume
protected abstract R resume(List<org.apache.kafka.clients.producer.ProducerRecord<byte[], byte[]>> deadLetterRecords) Create a response indicating that processing should resume.- Parameters:
deadLetterRecords- The list of dead letter records to forward to DLQ- Returns:
- a handler-specific resume response
-