Designer 10.15 | webMethods BPM Task Development Help | Working with Task Workflows | Key Implementation Points
 
Key Implementation Points
As you examine the sample implementation, make note of the following points:
Single path processing only
Software AG Designer enables you to create parallel data flows in a process model through the use of gateways and step joins and transitions. However, it is not possible to use a task workflow with parallel process branches where each branch might queue its own task instance. That is, you must avoid creating a situation where more than one task instance is running in parallel.
Task workflow correlation ID
A primary concept with the task workflow is that each object in the workflow must wait for the next task to fully instantiate before a transition occurs. This requires you to add a wait mechanism to each component in the workflow. You use a task workflow correlation ID to synchronize the waiting process component and the new task being queued.
This will ensure correct data flow through the process. The value of the task workflow correlation ID must be unique within the Process Engine environment.
Important:
The task workflow correlation ID is completely different from and unrelated to the standard document correlation ID often used in process implementation.
Prepare to wait
The first requirement in implementing the wait mechanism is to call:
TaskHelper.getTaskFormFlowService().waitPrepare(correlationID)
This returns a wait object to be used later to actually wait for notification with the correlation ID. It is very important to call waitPrepare()before starting a process or completing a task. Because these activities are executed in parallel, there is chance that the notification could be published before the wait is started and would then be missed.
Note:
When the very first activity step in your process model is a workflow task, you must implement the wait mechanism in the object that starts the process. For example, in the sample StartLoanProcess portlet, when the user clicks the Start Loan Process button, the first activity is to invoke waitPrepare. Then, the portlet starts the loan process. Example code can be found at: FormFlowProcessTasks\src\com\webmethods\caf\startloanprocess\ StartLoanProcessDefaultviewView.java
Waiting for task instantiation
The next part of the code is to wait for the new task being queued:
TaskHelper.getTaskFormFlowService().wait(waitObject, timeoutinmillis)
Notification
After the task is fully instantiated by the Process Engine, the task must notify any objects that are waiting for it. This is accomplished by adding a Queued event to the task and implementing an Invoke Service task action for the event that calls the following API:
TaskHelper.getTaskFormFlowService().notify(correlationID, result, false)
where result can be any value to be passed back to the waiting component. In the example, the result passes the taskURL of new task being queued. The code be found at:
FormFlowProcessTasks\src\com\webmethods\caf\taskclient\TaskStep1RuleContext.java
The Queued() action is the service invoked by the Task Queued event.
When the wait() call returns, the code checks the result of waitObject.getResult() which returns information from new task being queued. In the sample, this is the taskURL of the task being started.
Completing a task and waiting for the next task in the workflow
The basic behavior here is similar to that of starting a new process. However, instead of starting a process, the code completes the task and then waits for the next task to be queued. See the code sample in:
FormFlowProcessTasks\src\com\webmethods\caf\taskstep1view\ TaskStep1ViewDefaultviewView.java
The completeTask() action method addresses the completion requirement.
Ending the workflow from the process
Eventually a workflow task does not transition to a another workflow task, but instead completes the business process. In this case, the original CAF application may be waiting to be notified, but there is no new task to publish a notification. In this case it is the process model that knows the task workflow is complete.
The pub.task.taskclient:notifyFormFlow service in the WmTaskClient package accommodates this use case, enabling you to pass the correlation ID and a result:
pub.task.taskclient:notifyFormFlow (correlationID, result)
This service serves the same purpose as the notify() method of the Java API. It notifies any object waiting for a correlationID and passes a result. The result can be any value that the waiting thread can interpret as a signal to finish the task workflow (for example, it could be NULL, or it could be specific hard-coded value).
For more information about this and other task services, see the PDF publication webMethods Task Engine API and Service Reference. For general information about Task Engine services, see Working with the Task Engine APIs.
Related Topics