From 034131d9a733dc24577fd6982e2ee2385d7f5ecf Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 15 Sep 2020 17:27:20 +0200 Subject: [PATCH] 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 --- src/main/java/de/juplo/boot/data/jdbc/UserEventListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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()); -- 2.20.1