9 Replies Latest reply: Oct 8, 2012 11:49 AM by Leo C RSS

jBPM Timer usage

Mohamed Abuthahir Newbie

Hi,

 

I dont know how to configure the Timer in jbpm 5.2. My requirement is like my process should find the status in data base for every 5 minutes. And this should be happend for 2 hours.

 

In the Timer they had given properties like Timer Delay,Timer Period. But Timer Delay is used for the first execution. Timer Period is for repeatable execution. But that is not working for me.

 

Can you please help me on this issue..

 

Thanks

Abuthahir

  • 1. Re: jBPM Timer usage
    saig0 Newbie

    This behavior is not supported yet but you can use a workaround with two timers. Embed your process as subprocess and add a second timer as boundary event. The second timer has a delay of 2 hours and terminate the subprocess.

    TimerTest.png

  • 2. Re: jBPM Timer usage
    leaf-xue Newbie

    I also encountered this problem, you can tell me in detail under the two timers are configured attribute this?

  • 3. Re: jBPM Timer usage
    saig0 Newbie

    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.

     

    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>
    
  • 4. Re: jBPM Timer usage
    leaf-xue Newbie

    Hi saig0!

    Thank you very much for your reply, is very helpful for me!

    If I want to do a similar timing task flow, for example: a process inside a task over two hours and did not finish, then I will use email to remind the user.May I ask timer node can complete it? How to do it? Oh, add a bit, you know "0s###1s" is to follow a rule?What about his rule is?

  • 5. Re: jBPM Timer usage
    saig0 Newbie

    The following code is the configuration of the time event in jBPM. The expression "0s###1s" include the delay (0s) and the period (1s) of the timer.

     

    <timerEventDefinition>
         <timeCycle xsi:type="tFormalExpression">0s###1s</timeCycle>
    </timerEventDefinition>
    

     

     

    You can configure a boundary timer events if it should terminate the attached process or not then it fire. Just set the attribute "cancelActivity" on boundary event. So you can use it to build a remember function with a not terminating boundary timer event. Note that a boundary event can only attached to a process and not to a single activity.

     

    <boundaryEvent id="_5" name="Timeout" attachedToRef="_2" cancelActivity="false" >
          <timerEventDefinition>
            <timeDuration xsi:type="tFormalExpression">5s</timeDuration>
          </timerEventDefinition>
    </boundaryEvent>
    
  • 6. Re: jBPM Timer usage
    leaf-xue Newbie

    process.png

    As above, this painting process correctly?Boundary timer can only be placed in a subflow above?

  • 7. Re: jBPM Timer usage
    saig0 Newbie

    I used the jbpm eclipse plugin to create the process and can't attached the event on a single activity. Do you use guvnor? Does it run with jbpm? Which version of jbpm do you use?

     

    I think your process isn't correct if you just want to remember the user. If you use a termination end event "end3" the whole process instance will end.

  • 8. Re: jBPM Timer usage
    leaf-xue Newbie

    You are right, this process does not correct, I was in the designer2.2 draw flow chart.

  • 9. Re: jBPM Timer usage
    Leo C Newbie

    Hello guys, I really need some help here
    I still can't understand how to set up timer events, like: what to write in the properties, where to put the .xml file and if it needs to be named like the .bpmn file, and how to make the timer or the signal event be part of the task (like leaf-xue made for user2 task with a timer).

    Please, really can't figure it out by myself, I've searched on google but found nothing useful for this situation!

    Thanks all,

    regards

    Leo