jsr345-experts@ejb-spec.java.net

[jsr345-experts] Transaction timeout

From: Carlo de Wolf <cdewolf_at_redhat.com>
Date: Fri, 09 Dec 2011 12:35:02 +0100

Given the functionality of a transaction manager to set the transaction
timeout [1]. I would like to expose this feature in a spec defined manner.

How about the following annotation:

@Target({METHOD, TYPE})
@Retention(RUNTIME)
public @interface TransactionAttribute {
     TransactionAttributeType value() default
TransactionAttributeType.REQUIRED;
     long timeout() default -1L;
     TimeUnit unit() default TimeUnit.SECONDS;
}

Where -1 means unspecified.

And the following descriptor fragment:

<ejb-jar version="3.2">
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>A</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
<trans-timeout>
<timeout>10</timeout>
<unit>Seconds</unit>
</trans-timeout>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

What do you guys think?

Carlo

[1]
http://docs.oracle.com/javaee/6/api/javax/transaction/TransactionManager.html#setTransactionTimeout%28int%29

PS. Since people are going to dig, we discussed changing transaction
attributes on Oct 17th 2007.