Pages

Wednesday, June 15, 2011

EJB3 Method Invocation Timeouts

I have an application calling a remote method on a stateless session bean. This mehtod performs a whole heap of JPA transactions and thus can take quite some time to execute. The exact time is dependent on parameters passed in but mostly the call times out before the method can complete execution.

Something strange I noticed was that the JBoss TM doesn't actually stop the remote method, which continues execution (usually until completion) but only times out and aborts the method call. I would have thought the manager would want to interrupt any active thread that is running within a transaction that has timed out. But it seems you can control the two timeouts separately.

To control the EJB method timeout set the transaction timeout to a higher value. This can be done on a per method basis by annotating the method with

        @org.jboss.annotation.ejb.TransactionTimeout(600) // eg: a 10 minute timeout.

Or to apply the timeout setting to the entire bean:

        @ActivationConfigProperty(propertyName="transactionTimeout", propertyValue="600")

For bean managed transactions you can set the timeput pn the UserTransaction as follows:

        UserTransaction ut = (UserTransaction)ctx.lookup        ("java:someApp/someBean/SomeTransaction");
        ut.setTransactionTimeout(600);
        ut.begin();
        ...
        ut.commit();



To set the read timeout for remote method invocations in JBoss (6), update the following line in <JBoss home>/server/default/deploy/ejb3-connectors-jboss-beans.xml with:

        </parameter>
        <parameter>socket://${hostforurl}:${port}?timeout=600000</parameter>
        <parameter>

3 comments:

mary Brown said...

Java J2EE Online Training | Core Java Online Training

mary Brown said...

ml
Interesting Article

EJB 3 Online Training | Online Java Training

Java J2EE Online Training | Core Java Online Training

youthdestination said...

IAS Coaching in DELH

i love your bloge and It's very help full for me

ias cooaching

Post a Comment

 
Powered by Blogger