-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ueberfuhr-trainings/feature/exception-hand…
…ling Add retry and dlt handling.
- Loading branch information
Showing
4 changed files
with
78 additions
and
3 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
17 changes: 17 additions & 0 deletions
17
...a/de/sample/schulung/statistics/kafka/exceptions/CustomDeserializationFailureHandler.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,17 @@ | ||
package de.sample.schulung.statistics.kafka.exceptions; | ||
|
||
import org.springframework.kafka.support.serializer.FailedDeserializationInfo; | ||
|
||
import java.util.function.Function; | ||
|
||
public class CustomDeserializationFailureHandler<T> | ||
implements Function<FailedDeserializationInfo, T> { | ||
|
||
@Override | ||
public T apply(FailedDeserializationInfo failedDeserializationInfo) { | ||
// hier Fehler analysieren und eigenes Objekt erzeugen | ||
byte[] payload = failedDeserializationInfo.getData(); | ||
return null; // TODO | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...er/src/main/java/de/sample/schulung/statistics/kafka/exceptions/CustomJsonSerializer.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,23 @@ | ||
package de.sample.schulung.statistics.kafka.exceptions; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import org.springframework.kafka.support.JacksonUtils; | ||
import org.springframework.kafka.support.serializer.JsonSerializer; | ||
|
||
public class CustomJsonSerializer extends JsonSerializer<Object> { | ||
|
||
private static ObjectMapper createCustomObjectMapper() { | ||
final var result = JacksonUtils.enhancedObjectMapper(); | ||
result.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); | ||
result.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
result.registerModule(new JavaTimeModule()); | ||
return result; | ||
} | ||
|
||
public CustomJsonSerializer() { | ||
super(createCustomObjectMapper()); | ||
} | ||
} |
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