Well, the CDI spec requires to use a JTA Synchronization to notify transactional observer methods (see also 10.5. Observer notification) and thus this use case (fire an event and notify tx observers from another synchronization) simply cannot work. Moreover, CDI 2.0 clarifies what happens if a Synchronization callback cannot be registered (10.4.5. Transactional observer methods):
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.
So the current implementation aligns with the spec. If you think that such an use case should be supported pls create a feature request in the spec issue tracker. |