cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Job Executor giving problem in cluster environment

tkarthik26
Champ in-the-making
Champ in-the-making
Hi,
I am using activiti 5.17.0 and trying to implement my own job executor by extending org.activiti.engine.impl.jobexecutor.JobExecutor, but ended up getting UniversalConnectionPoolException while executing the jobs. Seems like if there are many jobs simultaneously running then this issue is coming. If I am not using any job executor, this exception is not coming. Can anyone throw some light on this one.

Below is the configuration:
<code>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="customDataSource" />
    <property name="history" value="full" />
    <property name="jobExecutorActivate" value="true" />
    <property name="jobExecutor" ref="customJobExecutor" />
</bean>

  <bean id="customJobExecutor" class="com.uprr.bpm.activiti.custom.CustomJobExecutor">
   <property name="queueSize" value="100"></property>
   <property name="corePoolSize" value="15"></property>
   <property name="maxPoolSize" value="50"></property> 
   <property name="keepAliveTime" value="30"></property>
  </bean>

ucp pool configuration
<ucpSmiley Tongueool-manager id="ncs.ucp.manager.bpe.enpr">
    <ucpSmiley Tongueooled-datasource id="ncs.ucp.datasource.bpe.enpr"
      user="${ncs.datasource.bpe.user}"
      password="${ncs.datasource.bpe.pwd}"
      url="${ncs.datasource.bpe.enpr.url}"
      fast-connection-failover-enabled="${ncs.datasource.bpe.fast-connection-failover-enabled}"
      ONS-configuration="${ncs.datasource.bpe.enpr.ONSConfiguration}"
      initial-pool-size="${ncs.datasource.bpe.pool.initial-pool-size}"
      max-pool-size="${ncs.datasource.bpe.pool.max-pool-size}"
      min-pool-size="${ncs.datasource.bpe.pool.min-pool-size}"
      max-statements="${ncs.datasource.bpe.pool.max-statements}"
      validate-connection-on-borrow="true"
      inactive-connection-timeout="${ncs.datasource.bpe.pool.inactive-connection-timeout}"
       login-timeout="${ncs.datasource.bpe.pool.login-timeout}" />
  </ucpSmiley Tongueool-manager>

ncs.datasource.bpe.fast-connection-failover-enabled = true
ncs.datasource.bpe.pool.max-pool-size = 50
ncs.datasource.bpe.pool.min-pool-size = 5
ncs.datasource.bpe.pool.initial-pool-size = 5
ncs.datasource.bpe.pool.max-statements=5
ncs.datasource.bpe.pool.inactive-connection-timeout = 60
ncs.datasource.bpe.pool.login-timeout = 10

Below is the exception:

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Exception occurred while getting connection: oracle.ucp.UniversalConnectionPoolException: All connections in the Universal Connection Pool are in use
   at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:241)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:424)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:348)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.jobexecutor.FailedJobListener.execute(FailedJobListener.java:47)
   at org.activiti.spring.SpringTransactionContext$4.afterCompletion(SpringTransactionContext.java:97)
   at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
<code>
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Please check your pool settings and the amount of connections you can create with your database user. The job executor needs a number of database connections to execute the SQL statements.

Best regards,

tkarthik26
Champ in-the-making
Champ in-the-making
I decreased the values to be equal to ucp connection pool properties but I get the same exception.
<code>
<bean id="customJobExecutor" class="com.uprr.bpm.activiti.custom.CustomJobExecutor">
   <property name="queueSize" value="5"></property>
   <property name="corePoolSize" value="5"></property>
   <property name="maxPoolSize" value="50"></property> 
   <property name="keepAliveTime" value="0"></property>
  </bean>
</code>

Below are my ucp pool configuration. The min-pool-size = 5 and max-pool-size = 50
<code>
<ucpSmiley Tongueool-manager id="ncs.ucp.manager.bpe.enpr">
    <ucpSmiley Tongueooled-datasource id="ncs.ucp.datasource.bpe.enpr"
      url="<some url>"
      fast-connection-failover-enabled="true"
      initial-pool-size="5"
      max-pool-size="50"
      min-pool-size="5"
      max-statements="5"
      validate-connection-on-borrow="true"
      inactive-connection-timeout="10" />
  </ucpSmiley Tongueool-manager>
</code>