Sunday, March 10, 2013

Transaction timeout error | Long running feeds| New transaction

If you had to run feeds that would take longer than appserver transaction timeout or any process that runs for ever and if you have see the transaction timeout exception as below for any long running processes

0ddf0003a SystemErr     R Caused by: org.omg.CORBA.TRANSACTION_ROLLEDBACK: javax.transaction.TransactionRolledbackException:  ; nested exception is:
      javax.transaction.TransactionRolledbackException: Transaction is ended due to timeout  vmcid: 0x0  minor code: 0  completed: No
0ddf0003a SystemErr     R    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
0ddf0003a SystemErr     R    at sun.reflect.NativeConstructorAccessorImpl.newInstance(

I would not advise this code solution for all scenarios and only after considering all scenarios, If you need to add code to create new transaction and manage your transactions. Find below code example.

Solution: Using new transaction in your code.

int transactionSize=5000; //example transaction size

for (int recordCount=0; recordCount <= recordsFromDB.length; recordCount++)

    //do business logic
    if ( (transactionSize != null) && (recordCount%transactionSize.longValue() == 0) ) {

catch (Exception e) {
                logging(METHOD_NAME, "Exception at performExecute" + e.getMessage());