Created
January 7, 2020 22:05
-
-
Save schroedermatt/923756374efc9f5afc685f089211acaa to your computer and use it in GitHub Desktop.
A custom implementation of a Kafka Streams ProductionExceptionHandler that uses a SpringContext bridge to access beans.
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
| public class CustomExceptionHandler implements ProductionExceptionHandler { | |
| private ExceptionService exceptionService; | |
| public ProductionExceptionHandlerResponse handle(final ProducerRecord<byte[], byte[]> record, final Exception exception) { | |
| boolean shouldContinue = exceptionService.handleProductionException(record, exception); | |
| return shouldContinue ? CONTINUE : FAIL; | |
| } | |
| @Override | |
| public void configure(Map<String, ?> configs) { | |
| // tap into SpringContext to get the ExceptionService bean | |
| this.exceptionService = SpringContext.getBean(ExceptionService.class); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment