cancel
Showing results for 
Search instead for 
Did you mean: 

Implement a waitstate with a timerevent

werners
Champ in-the-making
Champ in-the-making
Hi all,

maybe someone can give me some hint to solve the problem.

This is the subprocess:

startEvent → timerEvent → JavaServiceTask→ Exclusive Gateway  - endEvent

Depending on the result of  the service task, the exclusive gateway has to output-flows ( either to the endEvent or back to the timerEvent)

The timerEvent should cause a waiting time (in example one day) and either then the process will end (continue the parentprocess) or (depending on the result in serviceTask) sleep one day to retry.

I thought that it would be possible to implement this „waitstate“ easily with the following code:

<intermediateCatchEvent id="sid-00072" name="TimerCatchEvent">
        <timerEventDefinition>
          <timeDuration>P1D</timeDuration>
        </timerEventDefinition>
      </intermediateCatchEvent>

But when i execute the process, i get always the error message, and i think that the message is related to my timerEvent…



15 Jun 2014 22:29:01,183 [main] ERROR org.activiti.engine.impl.interceptor.CommandContext:140 - Error while closing command context
org.activiti.engine.ActivitiException: couldn't resolve duedate: 1
   at org.activiti.engine.impl.calendar.DurationBusinessCalendar.resolveDuedate(DurationBusinessCalendar.java:38)
…..

Is it possible to implement this waitstate with an timerevent? How can i do this and why is there a need for a duedate?

Thanks
Werner
9 REPLIES 9

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

which activiti version do you use?
Could you create jUnit test for this case?

Regards
Martin

werners
Champ in-the-making
Champ in-the-making
Hi Martin,

I’m using Activiti 5.14.
I think the error was caused by an individual error in my project and something went wrong during parse the „duedate“-string.
To be sure that my understanding concerning the timer event is correct, i tried to get a simple example running.

In my example there are only three service task which are only used to display some text via System.out.println(..) to be sure that these tasks were executed.

Between the first and the second servicetask there is a timer event, which was configured with the duration od „PT10S“.

StartEvent → ServiceTask1 → TimerEvent (10 seconds) -> ServiceTask2 – Usertask3(assignee kermit)-> EndEvent
For the JUnit Test in Eclipse, I set the value „jobExecutorActivate“ in the activity.cfg.xml to “true” , and I did the same in C:\apache-tomcat\webapps\activiti-explorer\WEB-INF\ activiti-standalone-context.xml.

<code>
<bean class="org.activiti.spring.SpringProcessEngineConfiguration" id="processEngineConfiguration"> <property ref="dataSource" name="dataSource"/> <property ref="transactionManager" name="transactionManager"/> <property name="databaseSchemaUpdate" value="true"/> <property name="jobExecutorActivate" value="true"/> <property name="mailServerPort" value="25"/> <property name="mailServerHost" value="192.168.1.10"/> -<property name="customFormTypes"> -<list> <bean class="org.activiti.explorer.form.UserFormType"/> <bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/> <bean class="org.activiti.explorer.form.MonthFormType"/> </list> </property> </bean>
</code>
If I run the process above via Junit-test the Usertask is shown in the activiti-explorer and I can complete the task to  finish.
But when I start the process in Activiti-Explorer via “start process button” in the “process” section , nothing happens visible happens and the usertask is not available for user Kermit.
Do I need to configure or add additional settings somewhere , to be able to use the timerEvent and to continue with my process in Activiti-Explorer or what is the reason for the different behavior from the same process.xml?

Thanks Werner

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Werner,

setting jobExecutorActivate to true should be enough.
Can you check DB tables (ACT_RU_JOB) or debug process execution to see what has happened?

Regards
Martin

werners
Champ in-the-making
Champ in-the-making
Hello  Martin,
thanks for your advice.
In Eclipse I set the log level to debug and found the following sql-statement regarding the table ACT_RU_JOB.
In my understanding is that the selection who collects and starts the open events.
<code> select * from ACT_RU_JOB RES LEFT OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_ where (RES.TYPE_ = 'timer') and (RES.DUEDATE_ is not null) and (RES.DUEDATE_ < '2014-06-18 20:05:11.069') and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < '2014-06-18 20:05:11.069') and (RES.RETRIES_ > 0) and ( (RES.EXECUTION_ID_ is null) or (PI.SUSPENSION_STATE_ = 1) ) order by DUEDATE_ ;
</code>
I started my process definition in activiti explorer again and extracted the row which was created from table ACT_RU-JOB as you mentioned above.
Extracted row:
<code>
INSERT INTO "act_ru_job" VALUES ('28', '1', 'timer', null, null, 't', '27', '23', 'timertest:1:116', '3', null, null, '2014-06-17 20:16:00.52', null, 'timer-intermediate-transition', 'timerintermediatecatchevent1');
</code>
But still nothing visible happens.

How can I check if the – “job acquisition thread” is running inside from tomcat? Or is there something missing in my activiti-standalone-context.xml
<code>

  <bean id="demoDataGenerator" class="org.activiti.explorer.demo.DemoDataGenerator" init-method="init">
    <property name="processEngine" ref="processEngine" />
   
    <!– Set following properties to false if certain demo data is not wanted –>
    <property name="createDemoUsersAndGroups" value="true" />
    <property name="createDemoProcessDefinitions" value="false" />
    <property name="createDemoModels" value="false" />
    <property name="generateReportData" value="true" />
  </bean>
 
  <bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:db.properties" />
    <!– Allow other PropertyPlaceholderConfigurer to run as well –>
    <property name="ignoreUnresolvablePlaceholders" value="true" />
  </bean>
   
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="defaultAutoCommit" value="false" />
  </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
   <property name="dataSource" ref="dataSource" />
  </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="mailServerPort" value="26"/>
   <property name="mailServerHost" value="192.168.1.10"/>
    <property name="customFormTypes">
      <list>
        <bean class="org.activiti.explorer.form.UserFormType"/>
        <bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/>
        <bean class="org.activiti.explorer.form.MonthFormType"/>  
      </list>
     
    </property>
  </bean>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
   <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  
  </bean>
 
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
  <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
 
  <bean id="activitiLoginHandler" class="org.activiti.explorer.ui.login.DefaultLoginHandler">
    <property name="identityService" ref="identityService" />
  </bean>
 
 
</beans>
</code>

Many thanks
Werner

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Werner,

I do not see anything strange in you spring context.

How can I check if the – “job acquisition thread” is running inside from tomcat? Or is there something missing in my activiti-standalone-context.xml

Run catalina in debug mode (catalina.sh jpda start)
Connect debuger to the remote JVM
Put break point to the job acquisition code.

Regards
Martin

werners
Champ in-the-making
Champ in-the-making
Hallo Martin,
thank you for you answer and sorry for asking again.
I enabled the remote debugger and made the breakpoint as you mentioned in your answer.
When I start my simple process in the activity-explorer, the process run into the timerevent  and I can see in debugger i.e. that the parsing  from duedate works well.
When the timerevent is processed, a new row  is inserted into the database (in table act_ru_job.)

Unfortunately in activity explorer it seems that there is no call from the “job acquisition thread” to table “act_ru_job”, because the debugger does not stop in the sourcecode and  the row in database remains  until I restart Tomcat. During the restart, all processes in the table  are executed correctly and the complete content of table act_ru_job is deleted.

Because i was not sure if jobExecutor is only inactive for some reason, and added the rows
<code>
<bean id="jobExecutorBean" class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
  <property name="maxJobsPerAcquisition" value="10"></property>
  <property name="waitTimeInMillis" value="100000"></property>
  </bean>
</code>
into my configuration file, because there is a similar description in the “book activiti in action” on page 184.

For now I would expect, that the timerevent itself would works well, because it is inserted into database, but that there is a reason or configuration issue why the “job acquisition thread” runs only on tomcats startup.

Do you have one more idea, how i can enable the aquisition-job or how i can find out why the query into Act_ru_job does not work?  

Thanks
Werner

trademak
Star Contributor
Star Contributor
Hi Werner,

If you enable the job executor, like it is by default in the Activiti Explorer it should work automatically. But with an intermediate catch timer event with P1D the job executor will wait for a whole day before the job will be executed.

Best regards,

werners
Champ in-the-making
Champ in-the-making
Hi Tijs, hello Martin,
in my simple testcase, I took PT10S for  the timerevent, so my expectation was to continue the process after 10 seconds.
Is there no possibility to find out why the event is not fired  and why there is no query in to table act_ru_job.
Is it correct, that the table “act_ru_job” should be empty, when the trigger is fired and the process was continued?

Best regards
Werner

jbarrez
Star Contributor
Star Contributor
> Is it correct, that the table “act_ru_job” should be empty, when the trigger is fired and the process was continued?

Correct.

So you are not seeing that?
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.