cancel
Showing results for 
Search instead for 
Did you mean: 

IntermediateCatchEvent :: not fired first time , but after re-running process it has been caught two times

fahad1
Champ in-the-making
Champ in-the-making
I am Experience a strange problem with IntermediateCatchEvent.

First run of process::  it is fired, but I am waiting so that it should be caught by task2. But it does not respond.

I again run the process to observe things

Second run of process: it is fired as in first run; and task2 get it twice ( runs twice) before termination.

Can anyone tel me what I am doing wrong.

<signal id="newMsg" name="newMsg"></signal>
  <process id="model5" isExecutable="true">
    <startEvent id="start" activiti:initiator="initiator"></startEvent>
    <userTask id="task1" name="task1" activiti:assignee="${initiator}">
       <extensionElements>
              <activiti:formProperty id="user" name="user" type="user" required="true"></activiti:formProperty>
              <activiti:formProperty id="name" name="name" type="string"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-16842953-EA94-42A2-B116-C68A98C85090" sourceRef="start" targetRef="task1"></sequenceFlow>
    <sequenceFlow id="sid-E2E35140-E272-4D5C-88A1-CD1039E6672B" sourceRef="task1" targetRef="serv1"></sequenceFlow>
    <sequenceFlow id="sid-9E02B791-B3C0-4B62-81BB-DA10424469DF" sourceRef="serv1" targetRef="s1"></sequenceFlow>
    <intermediateCatchEvent id="s1" name="s1">
      <signalEventDefinition signalRef="newMsg"></signalEventDefinition>
    </intermediateCatchEvent>
    <userTask id="task2" name="task2" activiti:assignee="${initiator}">
      <extensionElements>
        <activiti:formProperty id="prenom" name="prenom" type="string"></activiti:formProperty>
        <activiti:taskListener event="create" class="fitman.services.MyTaskListener"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-BC7E1EC1-6839-4440-A123-4127C00FAAA3" sourceRef="s1" targetRef="task2"></sequenceFlow>
    <sequenceFlow id="sid-5A09EDC9-7B1F-4BAD-8D3B-DEB53A01768A" sourceRef="task2" targetRef="serv2"></sequenceFlow>
    <sequenceFlow id="sid-1DCF980A-AB99-4839-A5BA-8900A1AA0D51" sourceRef="serv2" targetRef="end"></sequenceFlow>
    <serviceTask id="serv1" name="serv1" activiti:class="com.services.MyService1"></serviceTask>
    <serviceTask id="serv2" name="serv2" activiti:class="com.services.MyService2"></serviceTask>
    <endEvent id="end" name="end"></endEvent>
  </process>

12 REPLIES 12

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Could you share jUnit test with us please?
(http://forums.activiti.org/content/sticky-how-write-unit-test)

Regards
Martin

fahad1
Champ in-the-making
Champ in-the-making
ya sure I will share it if would not be solved by quick analysis. I am new may be I am doing something wrong. Here is my BPMN for your quick analysis, also see attached.
my process is very simple,
start>task1>signal throw> signal catch>task2>end

Why task2 will not fired in first run of this process ?

<signal id="newMsg" name="newMsg"></signal>
  <process id="myprocess1" isExecutable="true">
    <startEvent id="start" name="start" activiti:initiator="initiator"></startEvent>
    <userTask id="task1" name="task1" activiti:assignee="${initiator}">
      <extensionElements>
        <activiti:formProperty id="input1" name="input1" type="string"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-C8927327-04C5-406A-92AD-8157FC83C5D3" sourceRef="start" targetRef="task1"></sequenceFlow>
    <sequenceFlow id="sid-55F40D50-E590-4456-B17A-7BC437A5ACEE" sourceRef="task1" targetRef="s0"></sequenceFlow>
    <intermediateThrowEvent id="s0" name="s0">
      <signalEventDefinition signalRef="newMsg"></signalEventDefinition>
    </intermediateThrowEvent>
    <sequenceFlow id="sid-3048AB91-F055-4676-AFF8-6DA13FB9858E" sourceRef="s0" targetRef="s1"></sequenceFlow>
    <intermediateCatchEvent id="s1" name="s1">
      <signalEventDefinition signalRef="newMsg"></signalEventDefinition>
    </intermediateCatchEvent>
    <userTask id="task2" name="task2" activiti:assignee="${initiator}">
      <extensionElements>
        <activiti:formProperty id="name" name="name" type="string"></activiti:formProperty>
        <activiti:formProperty id="age" name="age" type="string"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-703F5DD1-1329-49E4-AFA3-7D35955CDB4E" sourceRef="s1" targetRef="task2"></sequenceFlow>
    <endEvent id="end" name="end"></endEvent>
    <sequenceFlow id="sid-FC91C55D-2D80-4655-8727-63A853CAE270" sourceRef="task2" targetRef="end"></sequenceFlow>
  </process>

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

try to split it into two processes.

Example from activiti jUnit tests


<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples"
  xmlns:tns="Examples">
 
  <message id="newInvoice" name="newInvoiceMessage" />
 
  <process id="process">
 
    <startEvent id="theStart" />
   
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="messageCatch" />
 
   <intermediateCatchEvent id="messageCatch">
    <messageEventDefinition messageRef="newInvoice" />
   </intermediateCatchEvent>
  
   <sequenceFlow id="flow2" sourceRef="messageCatch" targetRef="task" />
 
    <userTask id="task" name="Task" />
    <sequenceFlow id="flow3" sourceRef="task" targetRef="theEnd" />
   
    <endEvent id="theEnd" />
   
  </process>

</definitions>

(you can throw event from the process too)

  @Deployment
  public void testSingleIntermediateMessageEvent() {
   
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
   
    List<String> activeActivityIds = runtimeService.getActiveActivityIds(pi.getId());
    assertNotNull(activeActivityIds);
    assertEquals(1, activeActivityIds.size());
    assertTrue(activeActivityIds.contains("messageCatch"));
   
    String messageName = "newInvoiceMessage";
    Execution execution = runtimeService.createExecutionQuery()
      .messageEventSubscriptionName(messageName)
      .singleResult();
   
    assertNotNull(execution);

    runtimeService.messageEventReceived(messageName, execution.getId());
   
    Task task = taskService.createTaskQuery()
      .singleResult();   
    assertNotNull(task);
    taskService.complete(task.getId());
   
  }

Regards
Martin

fahad1
Champ in-the-making
Champ in-the-making
What do you mean by "try to split it into two processes",  can you explain in terms of my BPMN provided above ? Did you mean
file1 BPMN20.xml with :: start>task1>signal send>end
file2 BPMN20.xml with :: start>signal catch>task2>end.

It am doing this way as well, its not working? Same problem as above. In first run it will not invoke second BPMN process?  How to fix it? I have tested throw signal in implementation as well but the same problem. Can you just test the bpmn provided above?

Its seem to me a bug, what you think?? 

martin_grofcik
Confirmed Champ
Confirmed Champ
Process:

start>task1>signal send>signal catch>task2>end.

The first run:
After task1 complete signal is sent, but there is no process instance which is catching it. The first process instance waits for signal catching.

When you executes the second instance of the process, signal is fired (after task1 complete). The first process instance is catching this signal and continues in the execution (task2). The second process instance waits for signal.

Its seem to me a bug, what you think??
No

Regards
Martin

fahad1
Champ in-the-making
Champ in-the-making
thanks alot for your help.

so the solution is tosplit the process into two.
process1. start>task1>signal send>signal catch>task2>end.

new solution:
Process1 BPMN20.xml with :: start>task1>signal send>end
Process2 BPMN20.xml with :: start>signal catch>task2>end.

I am doing this way now. My questions: Is this a good solution ?? Do other solutions exist ?  How to merge both process1 and process 2 into a single, if possible?

martin_grofcik
Confirmed Champ
Confirmed Champ
What do you want to achieve with the process model?

fahad1
Champ in-the-making
Champ in-the-making
My process model is very complex and alot of people are communication. But let me explain you by only 2 persons involved in two different tasks, user is uploading and manager is fulfilling user's request. The summarized Scenerio is like this:
person_A  enteres some data, when he finishes, person_B has to perform some calculations. Therefore, first time I designed it like this:

start>task1 achieved by person_A>signal send>signal catch>task2  by person_B>end. Which you explained Why task_2 is not triggered.

Now what you propose me ?

martin_grofcik
Confirmed Champ
Confirmed Champ
Start>Task1>Task2>End