AnsweredAssumed Answered

How to Handle Errors due to Database Timeouts

Question asked by zlatan316 on May 7, 2015
Latest reply on May 14, 2015 by zlatan316
Hi,

I have implemented a Java class which is able to run MS Project Server Reports. These are generated via an external webservice. The method call which retrieves the report can sometimes take a while to return the report instance. Because the transaction for the Process in Activiti has been open for more than a few minutes, a database timeout occurs.

I was wondering if there was a way to capture these errors which are thrown by the Activiti Engine,

My catch block is as below which throws a BPMNError but the flow does not take the 'error route' when this particular timeout exception occurs.
<code>
       catch(Exception ex){
          SafeLogger.checkAndWriteToLog(ex.toString(), logger);
          ex.printStackTrace();
          throw new BpmnError(ex.toString());          
       }
<code>

The error stack trace is as follows
<code>
08:09:36,978 [pool-1-thread-53] ERROR org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessEnd  - Error while completing sub process of execution ProcessInstance[21415]
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 207,265 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.
### The error may exist in org/activiti/db/mapping/entity/IdentityLink.xml
### The error may involve org.activiti.engine.impl.persistence.entity.IdentityLinkEntity.selectIdentityLinksByProcessInstance-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_RU_IDENTITYLINK where PROC_INST_ID_ = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 207,265 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
        at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:286)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:277)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:272)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:253)
………………
<code>
Is there a way to capture these in Activiti?

Outcomes