cancel
Showing results for 
Search instead for 
Did you mean: 

call activity with attached timer boundary

alemser
Champ in-the-making
Champ in-the-making
Hello,

I have a diagram in which a user activity and a call activity has a timer boundary event attached (see attachment).
From the element timer of both activities, an outgoing sequence flow goes to a service activity.

When time out occours in the user activity, the activity is canceled as expected (cancelActiviry=true) and the service activity is reached. However, when timeout occours in the call activity, the service acivity is not reached… nothing happens.

Is that a bug or something I forgot to configure?
9 REPLIES 9

jbarrez
Star Contributor
Star Contributor
interrupting events are not yet fully implemeneted, hence why it probably doesnt work. Thats also the reason why we didnt document it so far.

alemser
Champ in-the-making
Champ in-the-making
ok, understand.

This part of process is important to our team and I would like to make some suggestions, if possible…
1. When timeout, and the attribute cancelActivity=false, today the engine creates a new task and keep the actual task activie. For our business, this is a problem, because the user see a duplicate task in your task list.
2. Possibility to add event listeners to timers, because in case of cancelActivity=false, it will be nice to notify the assignee that it is delayed and notify the manager about the delay.

thanks

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
1 might be a bug, but I would find that very strange. Do you have a small unittest?

2: so you don't want this to show up in yor process anywhere? I would personally prefer that, model it in.

alemser
Champ in-the-making
Champ in-the-making
About the test case, is a little bit hard to test this situation with the job executor activated. To test this scenario, I have to setup some infra-structure…

I put a service task in the diagram (duplicate.jpg), when the 'Register' completes, it creates a new 'Inspect' task (a new record on act_ru_task and act_ru_job is created)… and so on in a recursive way. I was wondering how can I provide this feature without create a new task (for shure setting cancelActivity=true), but then I got: org.activiti.engine.ActivitiException: this activity doesn't accept signals.

If I remove the service task (not_duplicate.jpg) the job executes and task remains OK.


About the event listeners ok, better show up… solving the problem above, the work is done. There is another way to send, for exemple, an e-mail when times out?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
About the test case, is a little bit hard to test this situation with the job executor activated. To test this scenario, I have to setup some infra-structure…
I never have the jobexecutor activated in unit tests… The unittest explicitly executes the jobs… See the unit tests for examples

I put a service task in the diagram (duplicate.jpg), when the 'Register' completes, it creates a new 'Inspect' task (a new record on act_ru_task and act_ru_job is created)… and so on in a recursive way. I was wondering how can I provide this feature without create a new task (for shure setting cancelActivity=true), but then I got: org.activiti.engine.ActivitiException: this activity doesn't accept signals.
Uhhmmm do not loop back to the user task? Or do I mis something…

If I remove the service task (not_duplicate.jpg) the job executes and task remains OK.
What is the definition of OK? No duplicate because you do not loop back to it

About the event listeners ok, better show up… solving the problem above, the work is done. There is another way to send, for exemple, an e-mail when times out?
Have you read the documentation? http://www.activiti.org/userguide/index.html#bpmnEmailTask

alemser
Champ in-the-making
Champ in-the-making
ok Ronald, thanks… I think that I mis something.

finally, I think that there is a bug when I have a timer attached to a call activity, because when times out, and the attribute cancelActivity=true, seems that the process go to a 'limbo' (like first image uploaded)

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Limbo? Like in doing nothing? What is the state in the db? Better yet, provide a small a unit test that demonstrates it.

alemser
Champ in-the-making
Champ in-the-making
I modified the file CallActivityTest.java from the activiti-engine-exemples project of Activiti 5.7 to reproduce the situation and it really works fine.

modifications:
1. set attribute jobExecutorActivate to true
2. modify the file CallActivityTest.java (is not so straightforward test with timers)

  @Deployment(resources={
    "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml",
    "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml"      
  })
  public void testOrderProcessWithCallActivity() {
    // After the process has started, the 'verify credit history' task should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
    TaskQuery taskQuery = taskService.createTaskQuery();
    Task verifyCreditTask = taskQuery.singleResult();
    assertEquals("Verify credit history", verifyCreditTask.getName());
   
    // Verify with Query API
    ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult();
    assertNotNull(subProcessInstance);
    assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId());
   
    // Completing the task with approval, will end the subprocess and continue the original process
    //alemser: commented to teste timer due date
    //taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
   
    //alemser: wait 10 seconds here to timer due date
    System.out.println("put a break point here and wait 10 seconds!");
   
    Task prepareAndShipTask = taskQuery.singleResult();
    assertEquals("Prepare and Ship", prepareAndShipTask.getName());
  }

3. modify the orderProcess.bpmn20.xml adding the boundary event and the service task

<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns:activiti="http://activiti.org/bpmn"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:smileysurprised:mgdi="http://www.omg.org/spec/DD/20100524/DI"
xmlns:smileysurprised:mgdc="http://www.omg.org/spec/DD/20100524/DC"
targetNamespace="Examples">

<process id="orderProcess" name="Order process with call activity">

  <startEvent id="theStart" />
  <sequenceFlow id="flow1" sourceRef="theStart" targetRef="receiveOrder" />

    <manualTask id="receiveOrder" name="Receive Order" />
    <sequenceFlow id="flow2" sourceRef="receiveOrder" targetRef="callCheckCreditProcess" />
   
    <callActivity id="callCheckCreditProcess" name="Check credit" calledElement="checkCreditProcess" />
    <sequenceFlow id="flow3" sourceRef="callCheckCreditProcess" targetRef="prepareAndShipTask" />
  
    <userTask id="prepareAndShipTask" name="Prepare and Ship" />


<!– alemser: new service task  –>
<serviceTask completionQuantity="1" id="_service_task" implementation="webService" isForCompensation="false" name="Registry"
   startQuantity="1" activiti:class="org.activiti.examples.bpmn.callactivity.MyJavaDelegate">
         <incoming>flowFromTimer</incoming>
         <outgoing>flowFromService</outgoing>
      </serviceTask>
     
      <!– alemser: new boundary timer  –>
      <boundaryEvent attachedToRef="callCheckCreditProcess" cancelActivity="true" id="_timer_boundary" name="" parallelMultiple="false">
         <outgoing>flowFromTimer</outgoing>
         <timerEventDefinition id="_theTimer">
            <timeDuration id="_theTimerDuration" xsi:type="tFormalExpression">PT10S</timeDuration>
         </timerEventDefinition>
      </boundaryEvent>

    <!– alemser: new sequence flows  –>
    <sequenceFlow id="flowFromTimer" sourceRef="_timer_boundary" targetRef="_service_task" />
    <sequenceFlow id="flowFromService" sourceRef="_service_task" targetRef="prepareAndShipTask" />
 
    <sequenceFlow id="flow4" sourceRef="prepareAndShipTask" targetRef="theEnd" />
   
<endEvent id="theEnd" />

</process>

</definitions>
4. finally create the java delegate to get work done

public class MyJavaDelegate implements JavaDelegate {

public void execute(DelegateExecution execution) throws Exception {
  System.out.println("[MyJavaDelegate] java delegate test"); 
}

}

I rewrote my original model in Oryx and, after redeploy it, works fine.
I think that all my problems is solved now.
thanks.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
great it works now, what was the last issue?

Oh and
modifications:
1. set attribute jobExecutorActivate to true
2. modify the file CallActivityTest.java (is not so straightforward test with timers)

There are several explicit timer tests and in lots of other tests the timers are used as well… Fireing them 'manually' is not difficult at all… just look at some examples