cancel
Showing results for 
Search instead for 
Did you mean: 

ExecutionListener was excuted 2 times, why?

wliang_bj
Champ on-the-rise
Champ on-the-rise
I encouter a question.

I defined a class named ExecutionCommentListner implements ExecutionListener, and defined it's event="end"; like below:

public class ExecutionCommentListner implements ExecutionListener {

   private static final long serialVersionUID = -6014971966749562667L;

   public void notify(DelegateExecution exec) throws Exception {
      // TODO Auto-generated method stub
      System.out.println(exec.getVariable("approved"));
      System.out.println(exec.getVariable("comment"));
      System.out.println(exec.getCurrentActivityName());
   }

}

when I complete the task node, I find ExecutionCommentListner was executed 2 times;

I got :

true
hello
null
true
hello
UserTask1

is this a bug , or did I do something wrong? BTW my version is 5.12
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
How does your BPMN XML look like?

wliang_bj
Champ on-the-rise
Champ on-the-rise
    <userTask id="directorAudit" name="ManagerAudit" activiti:assignee="${assignee}" activiti:formKey="audit.form">
      <documentation>${applyUserName} want to apply ${days} days and ${type}(${startTime}to${endTime}) holiday</documentation>
      <extensionElements>
        <activiti:executionListener event="end" class="cn.com.etib.iacframework.activiti.service.ExecutionCommentListner"></activiti:executionListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${security.getDirectorsByStarter(applier)}" activiti:elementVariable="assignee"></multiInstanceLoopCharacteristics>
    </userTask>

wliang_bj
Champ on-the-rise
Champ on-the-rise
Above is a period of my bpm description, did I do anything wrong?

mmaker1234
Champ in-the-making
Champ in-the-making
It seems that you have more than one instance of the <code>directorAudit</code> activity - depending on the content of the <code>security.getDirectorsByStarter(applier)</code> you receive messages (log records) for each activity instance.

wliang_bj
Champ on-the-rise
Champ on-the-rise
${security.getDirectorsByStarter(applier)} has only one result.
My situation is when I use ExecutionListner to listen to the task finish My listener was executed twoice, but when I change it to TaskListener, My listener was executed only once.

I have writer ExecutionCommentListner implements ExecutionListener and TaskCommentListner implements TaskListener to test the different situation.

frederikherema1
Star Contributor
Star Contributor
I'm guessing you're receiving one execution listener event for the task-instance being completed and another event when the whole multi-instance scope is completed… So in case you have a Munti-instance with 5 instances, you're execution-listener will be called 6 times. Can you validate this behavior?
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.