To add a "Timed-State" , we need to do the following
Upon entering the state, schedule a job using ScheduleExpiredStateActionHandler job
Upon leaving the state, cancel the scheduled job using CancelExpiredStateJobActionHandler job
Create a customized ExpiredStateAlertActionHandler
<state name="timed state"> <!-- schedule a job on entering the state --> <action> <delegation class="ScheduleExpiredStateActionHandler"> <!-- delegation configuration info --> </delegation> <action> <!-- cancel a job on leaving the state --> <action event-type="state-leave"> <delegation class="CancelExpiredStateJobActionHandler"></delegation> </action> </state>
-
Below is a typical but complete setup for a "time-state" in the process.xml
Please note that the <alert-delegation> element is optional, if it is not declared then default a ExpiredStateAlertActionHandler is assumed.
<state name="first state"> <assignment swimlane="operator1"></assignment> <action> <delegation class="com.greenfossil.jbpm.delegation.action.ScheduleExpiredStateActionHandler"> <![CDATA[ <job> <alert-delegation class="com.greenfossil.jbpm.delegation.action.ExpiredStateAlertActionHandler"></alert-delegation> <alert-email-addr>johndoe@foo.com</alert-email-addr> <alert-message>This state will not expire </alert-message> <expire-after>5s</expire-after> </job> \]\]\> </delegation> </action> <!-- Cancel ExpiredStateAlertActionHandler job --> <action event-type="state-leave"> <delegation class="com.greenfossil.jbpm.delegation.action.CancelExpiredStateJobActionHandler"> This action will be fired to cancel the scheduled job </delegation> </action> <transition to="second state" ></transition> </state>
Comments