jta-spec
  1. jta-spec
  2. JTA_SPEC-6

Clarify transaction interactions/restrictions in TX Synchronization callbacks

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Labels:
      None

      Description

      CDI observers may be registered as JTA synchronization callbacks (same applies to Stateful Session Beans). Nevertheless it is currently not clearly specified which JTA interactions are legal within those callback methods. The current EJB spec contains a few hints, however I believe those clarifications should be part of the JTA spec.

      In both cases - CDI observers and Stateful Session Beans - it is quite easy to execute transactional aware code within those callbacks. This includes interaction with an currently active transaction but also suspending/resuming a transaction in order to implement requires new semantics.

        Activity

        Hide
        frenchc added a comment - - edited

        See also https://issues.jboss.org/browse/CDI-213

        A few notes (from CDI spec ML).

        -----------------
        Marina Vatkina wrote:

        You can mark a transaction for rollback inside the beforeCompletion callback.

        BeforCompletion callback is part of the transaction commit process, so it's too late to request a commit. Nested transactions are not required to be supported, but you should be able to suspend/resume an active transaction to run a RequiresNew logic.

        AfterCompletion callback is called after all transaction processing has been finished.

        ------------------
        Paul Parkinson wrote:

        I think that may still leave the finer clarification of what is legal in beforeCompletion.  The introduction of the TransactionSynchronizationRegistry resulted in elaborating on the specification of Synchronization behavior (and of course beforeCompletion) as so the chapter 5 API ref is a better place to look, but indeed things like the ability to suspend/resume in a beforeCompletion method are not specified (the spec would actually seem to suggest that would not be legal/portable but at the same time I know it is possible, and likely used, in most if not all appservers).

        Show
        frenchc added a comment - - edited See also https://issues.jboss.org/browse/CDI-213 A few notes (from CDI spec ML). ----------------- Marina Vatkina wrote: You can mark a transaction for rollback inside the beforeCompletion callback. BeforCompletion callback is part of the transaction commit process, so it's too late to request a commit. Nested transactions are not required to be supported, but you should be able to suspend/resume an active transaction to run a RequiresNew logic. AfterCompletion callback is called after all transaction processing has been finished. ------------------ Paul Parkinson wrote: I think that may still leave the finer clarification of what is legal in beforeCompletion.  The introduction of the TransactionSynchronizationRegistry resulted in elaborating on the specification of Synchronization behavior (and of course beforeCompletion) as so the chapter 5 API ref is a better place to look, but indeed things like the ability to suspend/resume in a beforeCompletion method are not specified (the spec would actually seem to suggest that would not be legal/portable but at the same time I know it is possible, and likely used, in most if not all appservers).

          People

          • Assignee:
            Unassigned
            Reporter:
            frenchc
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: