cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti process timer DB entry

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

We have a scenario to notify the user with some message after 30 days. We have used the below code to initiate the timer:

<boundaryEvent id="timer1" name="Timer1" attachedToRef="subProcess" cancelActivity="false">
          <timerEventDefinition>
              <timeDuration>P30D</timeDuration>
          </timerEventDefinition>
<boundaryEvent>
<sequenceFlow id="flow17" sourceRef="timer1" targetRef="notifyUser"/>

When notification occurs after 30 day, but now for testing we have to tweak the framework to get the notification with the specified time. Can someone help us out with some tips to achieve it?

Any DB changes to set the timestamp which can tweak the  notification functionality?

Thanks in advance

-Darshan
5 REPLIES 5

darshan_hardas
Champ in-the-making
Champ in-the-making
Attached here with the timer code in the workflow.

darshan_hardas
Champ in-the-making
Champ in-the-making
Any help on this topic?

martin_grofcik
Confirmed Champ
Confirmed Champ
There are a lot of possibilities. What kind of tests do you want to run?

One proposal could be to use simulation and move process execution into virtual time. In that case you can achieve 30d delay independently from real time. Simulation framework: http://gro-mar.github.io/activiti-crystalball/

darshan_hardas
Champ in-the-making
Champ in-the-making
As per my understanding, when a workflow is initiated by processEngine, a DB entry to ACT_HI_PROCINST is made. Similarly for the timer if i change the creation date then the alert shown after 30 days can be tweaked.

Can somebody help us out with the DB table where the timer task is added?

martin_grofcik
Confirmed Champ
Confirmed Champ
Could following jUnit test help you?
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/test/java/org/activiti/...


  public void testInterruptingTimerDuration() {
   
    // Start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample");

    // There should be one task, with a timer : first line support
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("First line support", task.getName());

    // Manually execute the job
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());

    // The timer has fired, and the second task (secondlinesupport) now exists
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Handle escalated issue", task.getName());
  }

process definition:
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/test/resources/org/acti...

  <userTask id="firstLineSupport" name="First line support" activiti:assignee="kermit">
    <documentation>Fix issue raised by customer</documentation>
  </userTask>
  <sequenceFlow id="flow2" sourceRef="firstLineSupport" targetRef="normalEnd" />

  <endEvent id="normalEnd" />

  <boundaryEvent id="escalationTimer" cancelActivity="true" attachedToRef="firstLineSupport">
   <timerEventDefinition>
    <timeDuration>PT5M</timeDuration>
   </timerEventDefinition>
  </boundaryEvent>
  <sequenceFlow id="flow3" sourceRef="escalationTimer" targetRef="handleEscalation" />

  <userTask id="handleEscalation" name="Handle escalated issue" activiti:candidateGroups="management">
    <documentation>Escalation: issue was not fixed in time by first level support</documentation>
  </userTask>
  <sequenceFlow id="flow4" sourceRef="handleEscalation" targetRef="escalatedEnd" />