JBoss Community

Re: jBPM Timer usage

created by saig0 in jBPM - View the full discussion

Hi leaf-xue!

 

Here is the process with embedded timers. The inner timer fires every 1 second. The boundary timer fires after 5 seconds and end the process.

 

https://community.jboss.org/servlet/JiveServlet/downloadImage/2-758317-19430/450-264/TimerProcess.png

 

   <process processType="Private" isExecutable="true" id="TimerProcess" name="TimerProcess" tns:packageName="defaultPackage" tns:version="1" >
  
    <!-- nodes -->
    <startEvent id="_1" name="StartProcess" />
    <subProcess id="_2" name="Sub-Process"  >
    <!-- nodes -->
    <startEvent id="_2-1" name="Start" />
    <intermediateCatchEvent id="_2-2" name="Timer" >
      <timerEventDefinition>
        <timeCycle xsi:type="tFormalExpression">0s###1s</timeCycle>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <scriptTask id="_2-3" name="Action" scriptFormat="http://www.java.com/java" >
      <script>System.out.println("Action!");</script>
    </scriptTask>
    <endEvent id="_2-4" name="End" />
    <!-- connections -->
    <sequenceFlow id="_2-1-_2-2" sourceRef="_2-1" targetRef="_2-2" />
    <sequenceFlow id="_2-2-_2-3" sourceRef="_2-2" targetRef="_2-3" />
    <sequenceFlow id="_2-3-_2-4" sourceRef="_2-3" targetRef="_2-4" />
    </subProcess>
    <scriptTask id="_3" name="Timeout" scriptFormat="http://www.java.com/java" >
      <script>System.out.println("Timeout!");</script>
    </scriptTask>
    <endEvent id="_4" name="End" >
        <terminateEventDefinition/>
    </endEvent>
    <boundaryEvent id="_5" name="Timeout" attachedToRef="_2" >
      <timerEventDefinition>
        <timeDuration xsi:type="tFormalExpression">5s</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
  
    <!-- connections -->
    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
    <sequenceFlow id="_5-_3" sourceRef="_5" targetRef="_3" />
    <sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" />
  
  </process>

Reply to this message by going to Community

Start a new discussion in jBPM at Community