AnsweredAssumed Answered

timer to fire receiveTask

Question asked by javacorner on Mar 22, 2015
Latest reply on Mar 22, 2015 by javacorner
Dears,

I am implementing business workflow
my process is calling <strong>external system </strong>
I have to find some way to fix the case of the <strong>external system </strong> doesn't reply .
I am trying to use the solution of <em>jbarrez</em> at <a>http://forums.activiti.org/comment/14426#comment-14426</a>
<!–break–>
I added  <em>receiveTask</em> in case of error in<strong>external system </strong> call failure like following
<blockcode>
<receiveTask id="waitTimer" name="wait for timer"></receiveTask>
    <exclusiveGateway id="isCallBackendSuccess" name="Is Call Backend Success"></exclusiveGateway>
    <sequenceFlow id="continue" name="continue" sourceRef="isCallBackendSuccess" targetRef="servicetaskContinue">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${backendAnswered== true}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="backerror" name="backerror" sourceRef="isCallBackendSuccess" targetRef="waitTimer">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${backendAnswered== false}]]></conditionExpression>
    </sequenceFlow>
</blockcode>
<!–break–>
I created another process "cleanup " that will fire after time duration to search about all process instances that are waiting at "receiveTask" to send  "signal" to them to try to call the<strong>external system </strong> again like following
<blockcode>
<process id="timerCleanup" name="TimerCleanup" isExecutable="true">
    <startEvent id="timerstartevent1" name="Timer start">
      <timerEventDefinition>
        <timeDuration>PT2M</timeDuration>
      </timerEventDefinition>
    </startEvent>
    <serviceTask id="cleanupTask" name="cleanupTask" activiti:class="me.ffusion.bpm.javaDelegates.Cleanup"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="timerstartevent1" targetRef="cleanupTask"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="cleanupTask" targetRef="endevent1"></sequenceFlow>
  </process>
</blockcode>
<!–break–>
my question is how to implement the java delegate for the timer "cleanupTask" to about all process instances that are waiting at "receiveTask" to send  "signal" to them to try to call the external system again.

I want to loop for all these instances and run the following statement .
   
runtimeService.signal(waitStateExecution.getId());

Outcomes