Re: Re: accessing current transaction ID of EJB method?

"Hans J. Prueller" <[email protected]> Mon, 28 Feb 2011 21:29:39 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Organization LBS logics GmbH
Message-ID <1298924979.2125.11.camel@kodos>
thank you florent,

one thing i had to change was to lookup the local interface of the EJB
itself when calling itself to really force a new transaction to be
created,
annotating a inner private method doesn't work.

so what i did is in SLSB - doDataBatchProcessing is:

for(Client c: clients)
{
  //batch proc. for specific client
    BeanLocal local = lookupSelfLocal();
    local.batchProcessClient(c);
} 

with your tip looking up the UserTransaction via JNDI allowed us to
test/ prove it 

thank you / regards,

hans

Am Montag, den 28.02.2011, 18:06 +0100 schrieb Florent BENOIT:

>     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
> > 
> > 
> > 
> 
>