[jboss-user] [jBPM Users] - task & timers
jbosspnet
do-not-reply at jboss.com
Fri Dec 4 03:35:59 EST 2009
Hi.
I am using Jbpm 3.2.3 on Jboss 4.2.3.GA.
I have many processes where I have to check a condition in a manually or in a automatic way and the check have to be completed into a time range.
For this target, I use the following task-node:
| <task-node name="check" create-tasks="false" end-tasks="true">
| <event type="node-enter">
| <action class="org.process.StartCheck"></action>
| </event>
| <event type="node-leave">
| <action class="org.process.DefaultEnd"></action>
| </event>
|
| <timer name="check" duedate="2 seconds" repeat="4 seconds">
| <action class="org.process.CheckTimer"></action>
| </timer>
|
| <task name="check-manual">
| <event type="task-start">
| <action class="org.process.DefaultStart"></action>
| </event>
| <event type="task-end">
| <action class="org.process.DefaultEnd"></action>
| </event>
| </task>
|
| <task name="check-automatic">
| <event type="task-start">
| <action class="org.process.DefaultStart"></action>
| </event>
| <event type="task-end">
| <action class="org.process.DefaultEnd"></action>
| </event>
|
| <timer name="check-automatic" duedate="2 seconds" repeat="2 seconds">
| <action class="org.process.AutomaticCheck"></action>
| </timer>
| </task>
|
| <transition to="notify success" name="OK"></transition>
| <transition to="notify failure" name="KO"></transition>
| </task-node>
|
The manual check (first task) uses a form where the user manually clicks on OK/KO buttons.
Automatic check (second task) is performed with a class in the timer action that executes a query on a database and signal to the corret OK/KO transition.
To the events node-leave, node-enter, task-start and task-end are associated classes (DefaultStart and DefaultEnd) to trace the execution.
StartCheck creates the correct task (from a configuration parameter):
| public abstract class StartCheck implements ActionHandler {
| @Override
| public void execute(ExecutionContext executionContext) throws Exception {
| // get check type (manual or automatic)
| // checkType = ...
|
| // get the task-name from the check type (check-manual or check-automatic)
| // taskName = ...
|
| // create task instance
| TaskNode taskNode = (TaskNode) executionContext.getNode();
|
| Task task = taskNode.getTask(taskName);
|
| Token token = executionContext.getToken();
|
| TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
|
| TaskInstance taskInstance = tmi.createTaskInstance(task, token);
|
| taskInstance.start();
| }
| }
|
CheckTimer notifies if the check is over:
| public abstract class CheckTimer implements ActionHandler {
| @Override
| public void execute(ExecutionContext executionContext) throws Exception {
| // get time range (startDate and endDate) from configuration parameters
|
| // checks that new Date() is in the range (startDate, endDate)
|
| // notify user
| }
| }
|
AutomaticCheck executes the automatic check:
| public abstract class AutomaticCheckAction implements ActionHandler {
| @Override
| public void execute(ExecutionContext executionContext) throws Exception {
| // isOK is setted after a query on a database
| boolean isOK = ...
|
| Token token = executionContext.getToken();
| token.signal(isOK ? "OK" : "KO");
| }
| }
|
When the execution enters in this node, the task creation is correct and also the task-node timer is created.
If the check type is manual then the execution stops in the check-manual task and with the form we can select the OK/KO transition.
But if the check type is automatic, the timer associated with the check-automatic task is never created (in the JBPM_JOB table I find only the row that refers to the task-node timer) and the execution stops in this task forever due to the non-execution of the AutomaticCheck action.
Why the "check-automatic" task timer is not created?
Regards.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268939#4268939
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268939
More information about the jboss-user
mailing list