From: Kai Moritz Date: Tue, 15 Sep 2020 15:27:20 +0000 (+0200) Subject: Switchted to @TransactionalEventListener X-Git-Tag: part-1~6 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=034131d9a733dc24577fd6982e2ee2385d7f5ecf;p=demos%2Fspring%2Fdata-jdbc Switchted to @TransactionalEventListener * This listener ensures, that the event is fired in a specific tx-phase * The default-phase is AFTER_COMMIT, which fits our use-case perfectly --- diff --git a/src/main/java/de/juplo/boot/data/jdbc/UserEventListener.java b/src/main/java/de/juplo/boot/data/jdbc/UserEventListener.java index bdc6cb0..a9a2db2 100644 --- a/src/main/java/de/juplo/boot/data/jdbc/UserEventListener.java +++ b/src/main/java/de/juplo/boot/data/jdbc/UserEventListener.java @@ -2,8 +2,8 @@ package de.juplo.boot.data.jdbc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionalEventListener; @Component public class UserEventListener @@ -11,7 +11,7 @@ public class UserEventListener private static final Logger LOG = LoggerFactory.getLogger(UserEventListener.class); - @EventListener + @TransactionalEventListener public void onUserEvent(UserEvent event) { LOG.info("{}: {} - {}", event.getTime(), event.getStatus(), event.getKey());