cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed for Timer Events / Scheduler

mehrab365
Champ in-the-making
Champ in-the-making
Hi All,

I am new in Apache Activiti and I need some help.
I want to integrate Activiti with Spring Framework.
I have a simple task to create a Timer Events / Scheduler that will fire every 5 minute and execute a spring bean method.
I want to do it without any datasource or transaction manager configuration.

I did not find any good example on this simple task.

I need step by step code example to implement this task.

Please help me. Thanks in advance.

Mehrab
4 REPLIES 4

mehrab365
Champ in-the-making
Champ in-the-making
I just know in the forum, we do not configure Activity without DB. So please ignore the line "I want to do it without any datasource or transaction manager configuration."

Thanks,
Mehrab

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mehrab,

Check two 2 junit tests
org.activiti.engine.test.bpmn.event.timer.StartTimerEventTest
com.edorasware.gear.core.engine.support.activiti.ActivitiSpringBeanELResolverTest

in activiti source

Regards
Martin

Hi Maritn,

Thanks for reply. I have configured timer event that will fire every 1 minute . But it is firing 2 times in 1 minutes.
Here is my configuration, java method and log. Please help me to solve this issue.

  <process id="TimerAutoExec" isExecutable="true">
    <documentation>Timer Auto Exec</documentation>
    <startEvent id="start">
      <timerEventDefinition>
        <timeCycle>R/PT1M</timeCycle>
      </timerEventDefinition>
    </startEvent>
    <sequenceFlow id="flow_start" sourceRef="start" targetRef="retrieve_data"></sequenceFlow>
    <serviceTask id="retrieve_data" name="Retrieve New Data" activiti:class="com.epsilon.al.ml.manager.ActivitiDelegate"></serviceTask>
  <endEvent id="endevent1" name="End"></endEvent>
  </process>

public class ActivitiDelegate implements JavaDelegate {
private static final Logger logger = LoggerFactory.getLogger(ActivitiDelegate.class);
@Override
public void execute(DelegateExecution arg0) throws Exception {
  logger.info("——————–> Enter into delegate execute method");
}
}

2016-08-25_05:28:09.643 [pool-2-thread-2] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method
2016-08-25_05:28:43.098 [pool-4-thread-2] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method
2016-08-25_05:29:09.994 [pool-2-thread-3] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method
2016-08-25_05:29:43.256 [pool-4-thread-3] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method
2016-08-25_05:30:10.178 [pool-2-thread-1] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method
2016-08-25_05:30:43.363 [pool-4-thread-1] INFO  c.e.al.ml.manager.ActivitiDelegate - ——————–> Enter into delegate execute method

Thanks,
Mehrab

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mehrab,

Could you create jUnit test for that?
https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin