AnsweredAssumed Answered

Listeners do not work on Boundary Timer Event

Question asked by dinesh.babu.p on Oct 15, 2015
Latest reply on Sep 14, 2017 by sadiasher
In our project, we have a requirement of taking an auto-decision for a user task if the user is not closing this task in the given duration.

Technical implementation will have a user task and a timer boundary event attached to it. In order to cancel the user task upon timer expiry, below settings have been made(Cancel activity has been turned on).

The below flow works fine as long as there are no execution listeners(or invoking any java class through java service task) after timer boundary event, else an exception is thrown in the timer job and the error is :

“could not instantiate the class(the class invoked in execution listener of service/user task or any sequence flow which are called after timer boundary event)”.

Please note the same user task is at the beginning of the flow, and we are able to execute it’s listener successfully. After timer boundary event is fired, somehow the execution context is lost or not being supported.

Regarding process engine configuration, turning ‘JobExecutorActivate’ on is not making any difference , so it has been turned off and settings in the attached document has been followed.

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start">
<extensionElements>
<activiti:formProperty id="approval" name="Approval" type="string" default="Yes"></activiti:formProperty>
<activiti:formProperty id="taskId" name="TaskId" type="string"></activiti:formProperty>
</extensionElements>
</startEvent>
<userTask id="usertask4" name="Request Refund" activiti:assignee="kermit">
<extensionElements>
<activiti:formProperty id="employee" name="Employee" type="string" required="true"></activiti:formProperty>
<activiti:formProperty id="amount" name="Amount" type="long" required="true"></activiti:formProperty>
<activiti:formProperty id="motivation" name="Motivation" type="string" required="true"></activiti:formProperty>
<activiti:taskListener event="assignment" class="com.ms.msviz.activiti.workflow.servicetask.UserTaskJavaServiceTask"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow13" sourceRef="startevent1" targetRef="usertask4"></sequenceFlow>
<userTask id="usertask5" name="Handle Request" activiti:assignee="kermit">
<extensionElements>
<activiti:taskListener event="create" class="com.ms.msviz.activiti.workflow.servicetask.UserTaskCompletionJavaServiceTask"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow14" sourceRef="usertask4" targetRef="usertask5"></sequenceFlow>
<boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="usertask5" cancelActivity="false">
<timerEventDefinition>
<timeCycle>0 0/1 * * * ?</timeCycle>
</timerEventDefinition>
</boundaryEvent>
<serviceTask id="mailtask1" name="Mail Task" activiti:type="mail">
<extensionElements>
<activiti:field name="to">
<activiti:string><![CDATA[xxx@ms.com]]></activiti:string>
</activiti:field>
<activiti:field name="subject">
<activiti:string><![CDATA[Timer Testing]]></activiti:string>
</activiti:field>
<activiti:field name="text">
<activiti:string><![CDATA[Check]]></activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
<sequenceFlow id="flow15" sourceRef="boundarytimer1" targetRef="mailtask1"></sequenceFlow>
<boundaryEvent id="boundarytimer2" name="Timer" attachedToRef="usertask5" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT2M</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow16" sourceRef="usertask5" targetRef="endevent1"></sequenceFlow>
<userTask id="usertask6" name="Request Refund1">
<extensionElements>
<activiti:taskListener event="assignment" class="com.ms.msviz.activiti.workflow.servicetask.UserTaskJavaServiceTask"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow17" sourceRef="boundarytimer2" targetRef="usertask6"></sequenceFlow>
<sequenceFlow id="flow18" sourceRef="usertask6" targetRef="endevent1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
<bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="30.0" y="161.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
<omgdc:Bounds height="55.0" width="105.0" x="100.0" y="150.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
<omgdc:Bounds height="55.0" width="105.0" x="250.0" y="150.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="boundarytimer1" id="BPMNShape_boundarytimer1">
<omgdc:Bounds height="30.0" width="30.0" x="270.0" y="190.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="mailtask1" id="BPMNShape_mailtask1">
<omgdc:Bounds height="55.0" width="105.0" x="232.0" y="250.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="boundarytimer2" id="BPMNShape_boundarytimer2">
<omgdc:Bounds height="30.0" width="30.0" x="325.0" y="190.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="400.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask6" id="BPMNShape_usertask6">
<omgdc:Bounds height="55.0" width="105.0" x="380.0" y="230.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
<omgdi:waypoint x="65.0" y="178.0"></omgdi:waypoint>
<omgdi:waypoint x="100.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
<omgdi:waypoint x="205.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="250.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
<omgdi:waypoint x="285.0" y="220.0"></omgdi:waypoint>
<omgdi:waypoint x="284.0" y="250.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
<omgdi:waypoint x="355.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="400.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
<omgdi:waypoint x="355.0" y="205.0"></omgdi:waypoint>
<omgdi:waypoint x="432.0" y="230.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
<omgdi:waypoint x="432.0" y="230.0"></omgdi:waypoint>
<omgdi:waypoint x="417.0" y="195.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="deploymentResources" value="classpath*: src/main/resources/ActivitiDeployment.bpmn" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />

<!– <property name="jobExecutorActivate" value="true" /> –>
<property name="asyncExecutorEnabled" value="true" />
<property name="asyncExecutorActivate" value="true" />

<property name="enableDatabaseEventLogging" value="true" />
<property name="mailServerHost" value="xxx.ms.com" />
<property name="mailServerDefaultFrom" value="xxx@ms.com" />
</bean>

Outcomes