Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class UserEventListener {
private final UserRepository userRepository;
private final ObjectMapper objectMapper;
UserEventListener(UserRepository userRepository, ObjectMapper objectMapper) {
this.userRepository = userRepository;
this.objectMapper = objectMapper;
@KafkaListener(topics = "user-data")
void userDataListener(String eventData) {
UserRegistered event = eventFrom(eventData);;
private UserRegistered eventFrom(String eventData) {
try {
return objectMapper.readValue(eventData, UserRegistered.class);
} catch (JsonProcessingException e) {
throw new RuntimeException("Could not deserialize event", e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment