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?
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). – TuddorUserTransaction
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