Re: accessing current transaction ID of EJB method?

Florent BENOIT <[email protected]> Mon, 28 Feb 2011 18:06:13 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Message-ID <[email protected]>
    Hi Hans,

This should work as you're expecting it. But if there are failures 
between the run of batch clients, it will up to you to rollback 
something as each client batch is ran in its own transaction.

You may access the transaction by using JOnAS JNDI 
"javax.transaction.UserTransaction" object that you cast into 
javax.transaction.TransactionManager (and then you can perform 
getTransaction() on this manager which will print the XID of the 
transaction by using toString() method)

Regards,

Florent

Hans J. Prueller wrote:
> hi all,
>
> we are currently experimenting with EJB3-SLSB's 
> TransactionAttribe-Annotations on methods, especially  to handle 
> long-running batch jobs in a correct way:
>
> e.g. there is a single remote method of an EJB3 SLSB named:
>
> doDataBatchProcessing
>
> - currently method invocation takes about 1 hour which exceeds jtm 
> transaction timeout. as this is basically bad behaviour we want to 
> redesign
> it to  multiple short-time transactions instead of a single long-time 
> transaction by:
>
> doDataBatchProcessing: TransactionAttribeType.NOT_SUPPORTED
>
> and WITHIN doDataBatchProcessing another method is called "per client" -
>
> for(Client c: clients)
> {
>     //batch proc. for specific client
>     batchProcessClient(c);
> }
>
>
> where
> batchProcessClient(c) has TransactionAttributeType.REQUIRES_NEW
>
>
> --> this should result in several transactions for each single client 
> instead of a very long running single one -- is that correct?
>
> How can we test this - is there a way to lookup / access the current 
> CMT transaction ID  or similar ??
>
>
> thanks for any tips!
>
> regards,
> HANS
>
>
>