[JBoss JIRA] (CDI-705) BEFORE_COMPLETION Transactional observer is notified for transaction which is marked for rollback

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[JBoss JIRA] (CDI-705) BEFORE_COMPLETION Transactional observer is notified for transaction which is marked for rollback

JIRA issues@jboss.org

    [ https://issues.jboss.org/browse/CDI-705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13416960#comment-13416960 ]

Ondra Chaloupka edited comment on CDI-705 at 6/6/17 9:21 AM:
-------------------------------------------------------------

Tom already mentioned it so these are just my two cents: as I understand it, the main difference is in the fact that {{beforeCompletion}} is expected to be called with the active transaction context (by spec it's required). That provides the way for e.g. JPA (as Tom mentioned) to call flushes etc. That's are operations which are needed for data changes being made visible for the consumer - that's when the transaction *is going* to be committed. When the transaction *is not going* to be committed (was rolled back or marked to roll back) then first there is no need for such operations (and they could be considered as superfluous). Plus at that time the transaction context could not be available (as txn could be rolled back) and operations working on beforeCompletion context is expecting to use it.

The {{afterCompletion}} is expected to be called without active transaction context - that's true for commit and rollback. For both cases, the transaction already finished and there could not be any notion of it. Those cases are the same in that way.


was (Author: ochaloup):
Tom already mentioned it so these are just my two cents: as I understand it, the main difference is in the fact that {{beforeCompletion}} is expected to be called with the active transaction context (by spec it's required). That provides the way for e.g. JPA (as Tom mentioned) to call flushes etc. That's are operations which are needed for data changes being made visible for the consumer - that's when the transaction *is going* to be committed. When the transaction *is not going* to be committed (was rolled back or marked to roll back) then first there is no need for such operations (and they could be considered as superfluous) and at that time the transaction context could not be available.
The {{afterCompletion}} is expected to be called without active transaction context - that's true for commit and rollback. For both cases, the transaction already finished and there could not be any notion of it. Those cases are the same in that way.

> BEFORE_COMPLETION Transactional observer is notified for transaction which is marked for rollback
> -------------------------------------------------------------------------------------------------
>
>                 Key: CDI-705
>                 URL: https://issues.jboss.org/browse/CDI-705
>             Project: CDI Specification Issues
>          Issue Type: Bug
>          Components: Events
>    Affects Versions: 2.0 .Final
>            Reporter: Tomas Remes
>
> In {{10.4.5. Transactional observer methods}} CDI spec states:
> {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}
> This doesn't conform to JTA spec, which says in {{3.3.2 Transaction Synchronization}}:
> {quote}
> The Synchronization.beforeCompletion method is called prior to the
> start of the two-phase transaction commit process. This call is executed with
> the transaction context of the transaction that is being committed.
> {quote}
> So the before_completion transactional observer shouldn't be notified for transaction marked for rollback.
> The method {{Synchronization.beforeCompletion}} is actually not called at WildFly and GlassFish app servers for transaction which is marked for rollback.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
Loading...