cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat timers issue in Activiti 5.17.0

durani163
Champ in-the-making
Champ in-the-making
Hi Guys,

I have been working on Repeat timers on a user task using ISO date format. I have mentioned time duration: PT30S & time cycle: R4/PT30S. Below is the simple use case that I have been trying in a standalone application (Spring 3.0.4 & Hibernate 4.2.12 & JPA as entity manager factory) with activity engine (5.17.0).

Start -> User Task (Boundary Timer with time duration: PT30S & time cycle: R4/PT30S) -> Service Task -> End.

As per the above use case, if the user do not  approve within 30S, then the timer should invoke and service task should get invoked 4 times at 30S interval. But I could not be able to get success in the repeat timers. Only once, the service task gets executed.

Below is my configuration with spring:

1. activit-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
                  http://www.springframework.org/schema/beans/spring-beans.xsd">
                  
   <bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
      <property name="url" value="jdbcSmiley Surprisedracle:thin:@10.132.10.55:1522:HRMSLCL2" />
      <property name="username" value="sysadm" />
      <property name="password" value="sysadm123" />
   </bean>
   
   <bean id="jpaMF" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
       <property name="persistenceUnitName" value="org.jbpm.persistence.spring.local" />
           <property name="persistenceXmlLocation" value="classpath:spring/persistence.xml"/>
           <property name="jpaVendorAdapter">
         <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
           <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
         </bean>
           </property>
   </bean>

   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="jpaMF" />
   </bean>

   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jobExecutorActivate" value="true" />
      
      <property name="jpaEntityManagerFactory" ref="jpaMF" />
      <property name="jpaHandleTransaction" value="true" />
      <property name="jpaCloseEntityManager" value="true" />
      
      <property name="deploymentResources" value="classpath:sample/*.bpmn" />
        <property name="deploymentMode" value="single-resource" />
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>

   <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
   <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
   <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />

</beans>

2. Persistence.xml

<persistence
  version="2.0"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd
                      http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
  xmlnsSmiley Surprisedrm="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/persistence">

  <persistence-unit name="org.jbpm.persistence.spring.local" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
  
    <properties> 
      <property name="hibernate.id.new_generator_mappings" value="false" />
      <property name="hibernate.max_fetch_depth" value="3"/>
      <property name="hibernate.hbm2ddl.auto" value="update" />
      <property name="hibernate.show_sql" value="true" />
         
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
      <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
      <property name="hibernate.connection.url" value="<connection url>"/>
      <property name="hibernate.connection.username" value="sa"/>
      <property name="hibernate.connection.password" value=""/>
               
    </properties>       
  </persistence-unit>
   
</persistence>

Please help me out if I am missing any configuration related to timers in activity.

Thanks,
Feroze



9 REPLIES 9

balsarori
Champ on-the-rise
Champ on-the-rise
Only one timer definition can be set (timeDate, or timeDuration, or timeCycle). For your case set the timeCycle only.

Check the 8.2.2. Timer Event Definitions section of the user guide for more info.

http://activiti.org/userguide/index.html

durani163
Champ in-the-making
Champ in-the-making
Hi balsarori,

Thanks for your quick response. I have tried as mentioned above by having only the timer cycle definition and could not able to achieve the required behavior.

But I have a query related to your reply. I have tried the same use case in activity explorer by giving timerDuration and timeCycle. It is working fine in activity explorer. I could the service task is getting invoked repeatedly as per ISO date format. But If I try the same in standalone application having Activiti engine along with spring and Hibernate, I could not be able to achieve the same behavior.

Please help me out, as this is very much required for our business.

Thanks,
Feroze

jbarrez
Star Contributor
Star Contributor
>  But If I try the same in standalone application having Activiti engine along with spring and Hibernate, I could not be able to achieve the same behavior.

Did you verify the job executor is running?

> Please help me out, as this is very much required for our business.

The same applies to all posts on this forum. Well, almost all.

durani163
Champ in-the-making
Champ in-the-making
Hi jbarrez,

Thank you for the response. I have set the property 'jobExecutorActivate' to true in processEngineConfiguration bean and have started the processEngine in servletContextListener while server startup.

And, I could see that job is getting executed only once and could see a record in ACT_RU_JOB table, but could observe that REPEAT_ column value is blank even though I have provided R4/PT30S as time cycle value in a process file. Am I missing any configuration still ?

Please find the configuration below.

—–> processEngineConfiguration bean in spring-activiti.xml file

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="databaseType" value="oracle" />
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="jobExecutorActivate" value="true" />
  <property name="deploymentResources" value="classpath:sample/*.bpmn" />
    <property name="deploymentMode" value="single-resource" />
</bean>

—–> ProcessEnginesServletContextListener.java - which can be loaded at the server start up.

public void contextInitialized(ServletContextEvent servletContextEvent) {
  System.out.println("initialized…………");
  ProcessEngines.init();
  ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContextEvent.getServletContext());
  ProcessEngine processEngine = (ProcessEngine) appContext.getBean("processEngine");
  processEngine.getRuntimeService();  
}

jbarrez
Star Contributor
Star Contributor
Okay, could you paste your process xml too. And a unit test demonstrating the problem would be even more helpful for us to debug.
The fact it's running in a webapp should not make a difference regarding the job, the same issue should be visbible in a regular unit test. The fact the REPEAT_ column is empty doesn't necessarily mean anything.

muthyala
Champ in-the-making
Champ in-the-making
Hi jbarrez, We are also facing similar issue with timers. Here is the scenario we are trying. We have to send 5 emails if a user task is not approved with a duration of 2 Minutes.

Start event -> User Task (Boundary timer) -> if approved end
Boundary timer has R5,PT2M for time cycle followed by Mail task.

We see that 3 mails are triggered with a duration of 2M but the last 2 emails are sent at the same time as the third email. Eg (12:00,12:02, 12:04,12:04, 12:04 respectively ). Is this a known issue? If so is there any fix?

Alternatively we tried this second approach. In Boundary timer we have set time duration to 2M and then have the Mail task and then a intermediate catching timer. Intermediate catching timer has R4/PT2M. Intermediate catching timer followed by a service task to send email and also have a service task for repeating the loop.  But the intermediate catching timer has a job in the ACT_RU_JOB but then it does not throw any error and at the same time it does not execute the next service task for sending mails. Please suggest what is required to be done.

We are using 5.17.02and Jobexecutor is turned on.

thanks in Advance,
SM


yogi
Champ in-the-making
Champ in-the-making
I can confirm this as an issue as well. My timeCycle definition is as follows
<timerEventDefinition>
        <timeCycle>R5/PT1M</timeCycle>
</timerEventDefinition>

The execution starts the timer after 1 min of starting the task as intended. It works exactly for two repeats but when third arrives, all remaining repeats are fired simultaneously. as showing in the logs below:
DEBUG 11:31:02.379 [pool-5-thread-1]  za.co.xxxx.workflow.activiti.serviceTasks.SendEscalationNotification - Starting execution in SendEscalationNotification
DEBUG 11:32:02.537 [pool-5-thread-2]  za.co.xxxx.workflow.activiti.serviceTasks.SendEscalationNotification - Starting execution in SendEscalationNotification
DEBUG 11:33:02.694 [pool-5-thread-3]  za.co.xxxx.workflow.activiti.serviceTasks.SendEscalationNotification - Starting execution in SendEscalationNotification
DEBUG 11:33:02.815 [pool-5-thread-1]  za.co.xxxx.workflow.activiti.serviceTasks.SendEscalationNotification - Starting execution in SendEscalationNotification
DEBUG 11:33:02.932 [pool-5-thread-2]  za.co.xxxx.workflow.activiti.serviceTasks.SendEscalationNotification - Starting execution in SendEscalationNotification

vasile_dirla
Star Contributor
Star Contributor
@muthyala, it seems the xml you attached here is malformed.
whats' the source if "exclusivegateway2" ?

vasile_dirla
Star Contributor
Star Contributor
Just tested the boundary timer event with repeating interval: (Activiti 5.19)

I received these emails:
03:46:09 PM c_reddm@qualcomm.com c_reddm@qualcomm.com Test Teast
03:46:39 PM c_reddm@qualcomm.com c_reddm@qualcomm.com Test Teast
03:47:09 PM c_reddm@qualcomm.com c_reddm@qualcomm.com Test Teast
03:47:39 PM c_reddm@qualcomm.com c_reddm@qualcomm.com Test Teast
03:48:09 PM c_reddm@qualcomm.com c_reddm@qualcomm.com Test Teast

See attachment for the process definition I used.

as you can see there was 5 loops at 30 seconds repeat rate.

If you still have the issue please provide a unit test.