Why is there no @TransactionTimeout annotation for EJB3 CMT in Java EE
Asked Answered
A

0

16

For Container Managed Transactions (CMT) in EJB3, we have the following EJB annotations for Transaction Management.

  • @TransactionAttribute
  • @TransactionManagement

Unfortunately, there are no ways to set up transaction timeout and it's specific to each container. This means that I will have to "manage" transaction timeout for each specific Java EE EJB containers that I use.

For example, in Wildfly 9.x and higher, there is a org.jboss.ejb3.annotation.TransactionTimeout annotation that I can use. Alternatively, I can configure it in the JBoss EJB3 Deployment Descriptor. This will not work in containers outside Wildfly.

  • Is there a way to do CMT container managed transaction timeout that will run on any Java EE certified container?
  • Where can I find the default transaction timeout configuration value, particularly in Wildfly 9.x?
Adjuvant answered 13/5, 2016 at 7:55 Comment(7)
In wildfly global transactions are managed by the transactions subsystem (in your standalone*.xml file). The xml schema corresponding to this subsystem is here (you can also find it in your local wildfly docs/schema folder). You're interested in the default-timeout attribute which is set to 300 s (5mns).Tuddor
No, there is no standard way to manage the transaction timeout for a container-managed transaction. As for the title question, see java.net/jira/browse/EJB_SPEC-46 and java.net/jira/browse/EJB_SPEC-129.Tenebrific
@BrettKail Indeed, there's no standard for this and it has been asked many times before. I'm not exactly sure why Marina shot the proposal down (other than "the bean might be in a cluster" which wasn't discussed further), but this surely should warrant a second look. Also, don't forget the JTA "@Transactional", which could use this too. Best thing to get this moving forward would be too start the discussion on the Java EE, EJB and/or JTA spec mailing lists.Amphiaster
So, is there a way to propose this feature and get it "voted" to be included into the spec?Adjuvant
@ArjanTijms I suppose there are many things that could be added to the specs, and there is a complexity cost to weigh against the benefit that users would get out of it. It would be nice if EJB had an annotation and CDI had an annotation attribute (or whatever), but I imagine a custom CDI interceptor could be written to invoke UserTransaction.setTransactionTimeout?Tenebrific
@BrettKail I wonder if that will work, since UserTransaction is not exactly the same. Still a lot of things can indeed be implemented via utility code, but some of those utilities are written over and over and should perhaps better be part of the spec. I do agree that not blindly everything should be added (there's a support cost as well as steeper learning cost with a bigger API surface), but setting a transaction timeout is a quite fundamental thing and something has been used in a vendor specific way for a decade or longer.Amphiaster
@ArjanTijms No disagreements from me on any of your points :-).Tenebrific

© 2022 - 2024 — McMap. All rights reserved.