fix(mako): use @EventListener instead of @TransactionalEventListener
The MakoConsensListener was not being triggered because the event was published from a ScheduledExecutorService thread without transaction context. Changed to @EventListener @Transactional to fix this.
This commit is contained in:
parent
9d3fba05d6
commit
05ec18d550
@ -10,9 +10,9 @@ import at.mueller.eeg.backend.community.repository.MeteringPointRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.event.TransactionPhase;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@ -22,7 +22,8 @@ public class MakoConsensListener {
|
||||
private final MeteringPointRepository meteringPointRepository;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void handleMakoConsensApproved(MakoConsensApprovedEvent event) {
|
||||
log.info("MaKo-Consent erteilt für AT-Nummer: {}", event.atNumber());
|
||||
|
||||
@ -46,7 +47,8 @@ public class MakoConsensListener {
|
||||
}, () -> log.error("Zählpunkt mit AT-Nummer {} nicht gefunden.", event.atNumber()));
|
||||
}
|
||||
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void handleMakoConsensRejected(MakoConsensRejectedEvent event) {
|
||||
log.info("MaKo-Consent abgelehnt für AT-Nummer: {}. Grund: {}", event.atNumber(), event.reason());
|
||||
|
||||
@ -63,7 +65,8 @@ public class MakoConsensListener {
|
||||
}, () -> log.error("Zählpunkt mit AT-Nummer {} nicht gefunden.", event.atNumber()));
|
||||
}
|
||||
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
@EventListener
|
||||
@Transactional
|
||||
public void handleMakoConsensTechnicalFailed(MakoConsensTechnicalFailedEvent event) {
|
||||
log.warn("MaKo-Consent technischer Fehler für AT-Nummer: {}. Grund: {}", event.atNumber(), event.reason());
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user