This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/feature/interceptor' into feature/transactio…
…nal-outbox
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...vice-provider/src/main/java/de/sample/schulung/statistics/kafka/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; | ||
|
||
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()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...rvice-provider/src/main/java/de/sample/schulung/statistics/kafka/CustomerEventRecord.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 |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package de.sample.schulung.statistics.kafka; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
import java.util.UUID; | ||
|
||
public record CustomerEventRecord( | ||
@NotNull | ||
@Pattern(regexp = "created|replaced|deleted") | ||
String eventType, | ||
@NotNull | ||
UUID uuid, | ||
@Valid | ||
CustomerRecord customer | ||
) { | ||
} |
6 changes: 6 additions & 0 deletions
6
...cs-service-provider/src/main/java/de/sample/schulung/statistics/kafka/CustomerRecord.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package de.sample.schulung.statistics.kafka; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record CustomerRecord( | ||
@NotNull | ||
LocalDate birthdate, | ||
@NotNull | ||
@Pattern(regexp = "active|locked|disabled") | ||
String state | ||
) { | ||
} |
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