Created
December 7, 2019 23:00
-
-
Save mmornati/918c21238efb6442f103f33a7d8b925c to your computer and use it in GitHub Desktop.
Raise a Sprint ApplicatioEvent in a transactionalContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final ApplicationEventPublisher applicationEventPublisher; | |
@Transactional | |
public void myTransactionalMethod(Operation operation) { | |
service.storeOperation(operation); | |
sendEvent(operation.getId()); | |
} | |
private void sendEvent(Long operationId) { | |
OperationEvent event = new OperationEvent(operationId); | |
applicationEventPublisher.publishEvent(event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment