Yes the synchronization observer is an instance of javax.tranasaction.Synchronization, and is implemented in the weld-jta module: https://mvnrepository.com/artifact/org.jboss.weld.module/weld-jta/3.0.3.Final I agree that this is a question for some JTA experts, and the statement "Any Synchronization.afterCompletion methods will be invoked in an undefined context." needs clarification. Meanwhile, I've changed my code to:
/** |
* This transactional observer is no more annotated @Transactional, and it now schedules a transactional method |
* for a deferred execution. |
* |
* @param event the event. |
*/ |
private void onEvent(@Observes(during = TransactionPhase.AFTER_SUCCESS) String event) { |
LOGGER.info(() -> String.format("event received after success: %s", event)); |
Schedulers.single().scheduleDirect(() -> some.transactionalMethod()); |
}
|
But this is also causing an infinite loop, i.e. the same event is fired repeatedly if I don't set the synchronization observer instance to null. |