Skip to content

Commit

Permalink
fetch user from db before publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Erling Jahr committed Nov 20, 2023
1 parent 8e7991d commit 4746a3d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/no/fintlabs/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void save(User user) {
private Runnable onSaveNewUser(User user) {
return () -> {
User newUser = userRepository.save(user);
log.info("Create new user: " + user.getId());
//log.info("Create new user: " + user.getId());
memberService.process(memberService.create(newUser));
userEntityProducerService.publish(newUser);
};
Expand All @@ -51,10 +51,11 @@ private Runnable onSaveNewUser(User user) {
private Consumer<User> onSaveExistingUser(User user) {
return existingUser -> {
user.setId(existingUser.getId());
log.info("Update user: " + user.getId());
//log.info("Update user: " + user.getId());
memberService.process(memberService.create(user));
userRepository.save(user);
userEntityProducerService.publish(user);
User userToPublish = userRepository.findById(user.getId()).orElse(user);
userEntityProducerService.publish(userToPublish);
};
}

Expand Down

0 comments on commit 4746a3d

Please sign in to comment.