cancel
Showing results for 
Search instead for 
Did you mean: 

startEvent with Timer and repeat only executing once

celery
Champ in-the-making
Champ in-the-making
Hello,

Just started playing around with Activiti and am having trouble getting a timer to fire off multiple times.

I have a startEvent with a timer in my bpmn20.xml file:

<process id="TimerAutoExec" isExecutable="true">
    <documentation>Timer Auto Exec</documentation>
    <startEvent id="start">
      <timerEventDefinition>
        <timeCycle>R3/PT1M</timeCycle>
      </timerEventDefinition>
    </startEvent>

    <sequenceFlow id="flow_start" sourceRef="start" targetRef="retrieve_data"></sequenceFlow>
    <serviceTask id="retrieve_data" name="Retrieve New Data" activiti:class="gov.nasa.jpl.analytics.AutoRetrieveData"></serviceTask>


The serviceTask class is just creating a dummy file in my /tmp directory using the current timestamp as a filename.
Only one file ever gets created…but it should be firing off 3 times total, once every minute(for three files).

I've verified that the AsyncExecutor is enabled and activated in my config file so I think I might just be missing some easy "go" command to actually kick it off?

This is the entire content of my main method in my java code:


ProcessEngine processEngine =  ProcessEngines.getDefaultProcessEngine();
System.out.println("AsyncExecutor isActive: "
   + processEngine.getProcessEngineConfiguration().getAsyncExecutor().isActive());
      
String process_name = "TimerAutoExec";
String proc_id = processEngine.getRuntimeService().startProcessInstanceByKey(process_name).getId();
System.out.println("Spawning Workflow " + proc_id);
            
while(true)
{
   TimeUnit.SECONDS.sleep(60);
   System.out.println("Minute has passed, go check tmp!");
}


Any help you could provide would be greatly appreciated! Thanks!

-Celery
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
You are starting the process instance once manually (String proc_id = processEngine.getRuntimeService().startProcessInstanceByKey(process_name).getId():smileywink:, hence your one entry.

But in the while loop, there should be one file every minute, yes. Not sure why this isn't working …

Alternatively, you can try to use a cron expression.

celery
Champ in-the-making
Champ in-the-making
Hmm…using a cron seemed to have fixed the problem.  Would have liked to know why the other time expression didn't work…but I can live without it.  Thanks for your help!