[~jwgmeligmeyling] I see, I have only one small addition to the behaviour. The specification says (http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#observer_notification) {quote} If the transaction is in progress, but javax.transaction.Synchronization callback cannot be registered due to the transaction being already marked for rollback or in state where javax.transaction.Synchronization callbacks cannot be registered, the before completion, after completion and after failure observer methods are notified at the same time as other observers, but after_success observer methods get skipped. {quote} Which means that the observer (even marked with {{@Observes(during = TransactionPhase.*)}}) is executed just at time of `beforeCompletion` when the synchronzation fails. From that a kind of workaround could be to check the status of the transaction at method marked with ` {{ @Observes(during = TransactionPhase.AFTER_FAILURE) ` }} :
* {{((javax.transaction.TransactionManager) new javax.naming.InitialContext().lookup("java:/TransactionManager")).getStatus() == javax.transaction.Status.STATUS_ACTIVE}} - failure on the synchronization registration * {{((javax.transaction.TransactionManager) new javax.naming.InitialContext().lookup("java:/TransactionManager")).getStatus() == javax.transaction.Status.STATUS_ROLLEDBACK}} - the synchronization registration succeeded but the transaction failed to proceed and was rolled-back |
|