Make connection pool of MyBatis configurable

Description

When using Activiti standalone (ie not used with Spring for example), when using multiple threads to run processes, the default connection pool of MyBatis quickly fails due to not having enough connections:

  1.  

    1.  

      1. Error closing transaction. Cause: org.apache.ibatis.datasource.DataSourceException: Error accessing PooledConnection. Connection is invalid.

      2. Cause: org.apache.ibatis.datasource.DataSourceException: Error accessing PooledConnection. Connection is invalid.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.close(DefaultSqlSession.java:149)
        at org.activiti.engine.impl.db.DbSqlSession.close(DbSqlSession.java:387)
        at org.activiti.engine.impl.interceptor.CommandContext.closeSessions(CommandContext.java:150)
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:122)
        at org.activiti.engine.impl.interceptor.DefaultCommandExecutor$InternalCommandContextCreator.invoke(DefaultCommandExecutor.java:132)
        at org.activiti.engine.impl.interceptor.DefaultCommandExecutor$InternalCommandInterceptorChain.execute(DefaultCommandExecutor.java:95)
        at org.activiti.engine.impl.interceptor.DefaultCommandExecutor.execute(DefaultCommandExecutor.java:57)
        at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:42)

When using Spring, this issue is fixed since the datasource wrappers implement connection pooling.

Currently, the DbSqlSessionFactory reads the file activiti.ibatis.mem.conf.xml, and changes the jdbc params if needed.
It's this very same file that needs to be adjusted when the default connection pool of MyBatis needs to be changed.

Possible strategies:

  • configuration in activiti.properties

  • allow to provide a custom ibatis.conf.xml

  • something even more clever

Assignee

Joram Barrez

Reporter

Joram Barrez

Labels

None

Fix versions

Priority

Major
Configure