I have a spring java custom event class record StateChangeEvent( StateChangeAware…
- User
I have a spring java custom event class record StateChangeEvent( StateChangeAware entity, StatusType oldStatus, StatusType newStatus ) { } and a place where i publish this event : eventPublisher.publishEvent(new StateChangeEvent(entity, entity.getStatus(), nextStatus));
I also have a Listener:
@TransactionalEventListener public void handleEvent(StateChangeEvent event) {
code}annotated with @Service
But the listener does not trigger when an event is send. If i use @EventListener instead of @TransactionalEventListener, the listener triggers. I know for sure, that i am in a transaction context because TransactionSynchronizationManager.isActualTransactionActive() tells me that one transaction is open. What is the problem here and how can i resolve it?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.