* 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
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
private static final Logger LOG = LoggerFactory.getLogger(UserEventListener.class);
- @EventListener
+ @TransactionalEventListener
public void onUserEvent(UserEvent event)
{
LOG.info("{}: {} - {}", event.getTime(), event.getStatus(), event.getKey());