WebSphere Process Server (WPS) is a powerful business process automated engine with high performance which provides perfect runtime support for all kinds of process. And WebSphere Integrated Developer (WID), as the development tool for applications running on WPS, can be used by customers to model their workflow visually. Customers just need drag-and-drop without any coding. The executable BPEL code will be generated automatically. Comparing with other BPEL engine products, Customers can implement the Workflow Patterns Initiative (WPI) 43 patterns with the latest WID v7.0 and WPS v7.0 more easily and graciously.
We have previously the 34 patterns with implementation in parts 1, 2 and 3. In part 4 of this article, the last three categories patterns 1-State-based Patterns, 2-Termination Patterns and 3-Trigger Patterns will be introduced in detail.
There are 5 basic patterns in this category, including:
- Deferred choice
- Interleaved parallel routing
- Milestone
- Critical section
- Interleaved routing
With those patterns, customer can implement most kinds of state based process easily.
This pattern requires the ability to defer the moment of choice in a process. And decision is based on factors external to the process instance (e.g. incoming messages, environment data, resource availability, timeouts etc.)
For example, in bank credit card apply process, after applicant submits request, human task credit check is performed whose result determines which branch to take afterwards. Read the complete pattern detail description here.
The focus of this pattern is:
- In a process, there is a point for external information to decide following branch.
- External information includes incoming messages, environment data, resource availability, timeouts etc.
- After the decision is made, execution alternatives in branches other than the one selected are withdrawn.
In WID, we can use human task and choice to implement this.
Figure 1. Deferred Choice Implementation
Which case to go is decided by human task node "InputDeferredChoice". If field2 is 1, process goes into Case1; if field2 is 2, process goes into Case2; if field2 is other number, process goes into Case3.
Run on WebSphere Process Server
If input "1" is a human task, the process will run into Case1 (verified in the below log).
Listing 1. Deferred Choice Log
[8/23/10 14:52:16:453 GMT+08:00] 0000004e SystemOut O [Sequence] Run into Case1 |
This pattern requires relaxing the strict ordering that a process usually imposes over a set of tasks. All tasks should be executed all, but only one task can be executed at the same time.
For example, in dispatching order process of an online store, pick goods, pack goods and prepare invoice tasks must be completed. The pick goods task must be done before the pack goods task. The prepare invoice task can occur at any time. Only one of these tasks can be done at any time for a given order. Full pattern detail description is located here.
The focus of this pattern is:
- A set of tasks has a partial ordering defined.
- Each task in the task set must be executed once and they can be completed in any order that accords with the partial order.
- Just one task can be executing at the same time.
In WID, we can use Isolated Scope and Fork Gateway to implement this pattern easily.
Figure 2. Interleaved Parallel Routing Implementation
Task C should be executed after Task A, that is the defined partial ordering. After Fork Gateway, two lines of tasks are started, Wait1 and Wait2 controls which task (Task A or Task B) be executed firstly. At the end of the process, the process will go to "PrintResult" activity.
Note: Each scope should be defined as "isolated" (in Property Detail tab). It ensures those isolated scopes are executed in sequence actually in runtime. That means at the same time, just one isolated scope can be executing.
Run on WebSphere Process Server
Listing 2. Interleaved Parallel Routing Log
[9/6/10 15:49:20:000 GMT+08:00] 00000097 SystemOut O
[run InterleavedParallelRouting] and the
sequence is : [runHumanTaskA] -> [runHumanTaskB] -> [runHumanTaskC] -> End.
|
This pattern provides a mechanism for supporting the conditional execution of a task or sub-process (possibly on a repeated basis) where the process instance is in a given state. As such, it provides a means of synchronizing two distinct branches of a process instance, such that one branch cannot proceed unless the other branch has reached a specified state.
For example, in bank account request process, before bank staff issue request starts, customer can update information in the request. Once issue request completed, customer can not update information in the request any more. The full pattern detail description is located here.
The focus of this pattern is:
- One task is only enabled when the process instance is in a specific state.
- The state is assumed to be a specific execution point (also known as a milestone) in the process model.
- When the milestone is reached, the nominated task can be enabled.
- If the process instance has progressed beyond this state, then the task cannot be enabled now or at any future time
In WID, we use Fork, Join and Split Gateway with conditioned link in GeneralizedFlow to implement this pattern.
Figure 3. Milestone Implementation
Task Trigger is the milestone of Task E. If Task Trigger is enabled and Task DeferChoice is uncompleted, branch Task E can be enabled and roll back to Task D. Use variable "istri" to mark Task Trigger is enabled or not; variable "EorF" to control which branch (TaskE or TaskF) to taken after Task DeferChoice.
Note:
- In runtime, if the Task Trigger is enabled after Task DeferChoice instance been created, available choice (which is passed into DeferChoice task as input parameter) will not be refreshed anyway.
- Error path is added after DeferChoice in case user chooses Task E when Trigger is disabled which is not allowed. That way, one new DerferChoice instance will be created for user’s correct choice.
Run on WebSphere Process Server
Execution Steps:
- Start the process instance
- Claim Task Trigger
- Complete Task DeferChoice (output is "E")
- Complete Task Trigger (output is "false")
- Complete Task DeferChoice (output is "F")
Listing 3. Milestone Log
[9/27/10 16:32:07:109 GMT+08:00] 00000054 SystemOut O Enter Start
[9/27/10 16:32:07:109 GMT+08:00] 00000054 SystemOut O Enter D
[9/27/10 16:32:07:109 GMT+08:00] 00000054 SystemOut O Enter A
[9/27/10 16:32:45:500 GMT+08:00] 00000054 SystemOut O Enter E
[9/27/10 16:32:45:500 GMT+08:00] 00000054 SystemOut O Enter D
[9/27/10 16:33:17:609 GMT+08:00] 00000054 SystemOut O Enter F
[9/27/10 16:33:17:609 GMT+08:00] 00000054 SystemOut O Enter G
[9/27/10 16:33:29:703 GMT+08:00] 00000054 SystemOut O Enter C
[9/27/10 16:33:29:718 GMT+08:00] 00000054 SystemOut O Enter End
|
This pattern provides a means of limiting two or more sections of a process from executing concurrently. It is necessary if tasks within this section require exclusive access to a common resource (either data or a physical resource) necessary for a task to be completed.
For example, in the holiday booking process, both the take-deposit and insurance-payment tasks require the exclusive use of the credit-card-processing machine. Consequently only one of them can execute at any given time. Read further about the attern detail description here.
The focus of this pattern is:
- Two or more connected sub graphs of a process model are identified as "critical sections".
- At runtime for a given process instance, only tasks in one of these "critical sections" can be active at any given time.
In WID, we can use WhileLoop with defined token variable to implement this.
Figure 4. Critical Section Implementation
The scope in each path is the defined “critical sections”. Once one path enters the scope, it will hold the token variable till completed. Another path will keeps waiting and will not be able to execute the critical sections till the token is released.
Run on WebSphere Process Server
Execution Steps:
- Start the process instance
- Complete HumanTask1
- Complete HumanTask
- Complete HumanTask3
- Complete HumanTask2
Listing 4. Critical Section Log
[9/6/10 18:05:20:765 GMT+08:00] 00000071 SystemOut O Process Starts
[9/6/10 18:05:37:312 GMT+08:00] 00000075 SystemOut O Process2 starts
[9/6/10 18:05:37:375 GMT+08:00] 00000075 SystemOut O Run into Critical Section 2
: true
[9/6/10 18:05:49:687 GMT+08:00] 00000075 SystemOut O Process1 starts
[9/6/10 18:05:49:703 GMT+08:00] 00000075 SystemOut O Process1 is waiting
[9/6/10 18:05:54:953 GMT+08:00] 00000045 SystemOut O Process1 is waiting
[9/6/10 18:06:00:000 GMT+08:00] 00000045 SystemOut O Process1 is waiting
[9/6/10 18:06:05:031 GMT+08:00] 00000044 SystemOut O Process1 is waiting
[9/6/10 18:06:05:109 GMT+08:00] 00000075 SystemOut O Process2 finished
[9/6/10 18:06:05:109 GMT+08:00] 00000075 SystemOut O Process2 release the token
[9/6/10 18:06:10:062 GMT+08:00] 00000044 SystemOut O Run into Critical Section 1
: true
[9/6/10 18:06:24:984 GMT+08:00] 00000075 SystemOut O Process1 finished
[9/6/10 18:06:24:984 GMT+08:00] 00000075 SystemOut O Process1 release the token
[9/6/10 18:06:24:984 GMT+08:00] 00000075 SystemOut O All Processes Finished
|
This pattern allows a sequence of tasks to be executed in any order, but no two tasks can be executed at the same time.
For example, the check-oil, test-feeder, examine-main-unit and review-warranty tasks all need to be undertaken as part of the machine-service process. Only one of them can be undertaken at a time; however they can be executed in any order.
Note: This pattern is similar to pattern Interleaved Parallel Routing. Difference is that pattern Interleaved Parallel Routing has partial ordering restriction, while this pattern does not have any ordering restriction and allows a sequence of tasks to be executed in any order.
Full Pattern detail description is located here.
The focus of this pattern is:
- Each member of a set of tasks must be executed once.
- Tasks can be executed in any order but no two tasks can be executed at the same time.
- Once all of the tasks have completed, the next task in the process can be initiated.
In WID, we use Fork Gateway and WhileLoop with a token variable to implement this.
Figure 5. Interleaved Routing Implementation
Branch1, Branch2 and Branch3 are enabled together, based on the execution order which is defined in the input business data, Case1, Case2 and Case3 will be executed accordingly. When one case is executing (it holds the token), other uncompleted branches are waiting till the token is released.
Run on WebSphere Process Server
Listing 5. Interleaved Routing Log
[9/7/10 9:39:41:890 GMT+08:00] 0000007b SystemOut O process starts
[9/7/10 9:39:41:890 GMT+08:00] 0000007b SystemOut O branch2 is ready
[9/7/10 9:39:41:921 GMT+08:00] 0000007b SystemOut O branch1 is ready
[9/7/10 9:39:41:921 GMT+08:00] 0000007b SystemOut O branch3 is ready
[9/7/10 9:39:42:015 GMT+08:00] 0000007b SystemOut O branch2 is waiting
[9/7/10 9:39:42:031 GMT+08:00] 0000007b SystemOut O Case1 finish
[9/7/10 9:39:42:046 GMT+08:00] 0000007b SystemOut O branch3 is waiting
[9/7/10 9:39:44:250 GMT+08:00] 00000044 SystemOut O Case2 finish
[9/7/10 9:39:44:468 GMT+08:00] 00000045 SystemOut O Case3 finish
[9/7/10 9:39:44:468 GMT+08:00] 00000045 SystemOut O process completes
|
There are 2 patterns in this category, including:
- Implicit Termination
- Explicit Termination
Those patterns are widely used when a workflow is considered to be completed. They provide way to terminate a business instance implicitly or explicitly.
This pattern requires a given process (or sub-process) instance should terminate when there are no remaining work items that are able to be done and the process instance is not in deadlock. That provides a way to determine the process instance has been completed successfully. It’s a very common requirement in all kinds of process.
For example, in bank credit card apply process; after all tasks are completed as designed, the whole process instance should be completed successfully. Read further about the patten detail description here.
The focus of this pattern is:
- Process instance should terminate when there are no remaining work items.
- The process is marked completed successfully
WID supports this by default. When work items in one process have all completed as designed, the process instance is completed successfully.
Figure 6. Implicit Termination Implementation
Two branches are performed in sequence. After all nodes (NodeA~NodeE) completed, the process are terminated and marked as completed successfully.
Run on WebSphere Process Server
Execution Steps:
- Start the process instance.
- Complete human task NodeB, NodeC, NodeD, NodeE in order.
Then the process instance are terminated, and marked as "Finished" (verified in below picture) which means completed successfully.
Note: By default, process instance will be removed if it is completed successfully. Need to configure "Automatically delete the process after completion" (in the process property detail tab) to "NO". That way, you can check the successfully finished process instance.
This pattern requires a given process (or sub-process) instance should terminate when it reaches a nominated state. Usually it is a specific end node. When this end node is reached, any remaining work in the process instance is cancelled. As a result, the overall process instance is recorded as having completed successfully. Read about this pattern description in detail here.
The focus of this pattern is:
- Given process instance is terminated when it reaches a specific end node.
- Any remaining work in the process instance is cancelled.
- Overall process instance is recorded as having completed successfully
In WID, we can use Throw and Fault Handler to implement this pattern easily.
Figure 7. Explicit Termination Implementation
After the process instance starts, human task Task1 is created. At the same time, Choice will be made to take which branch. If it turns into 1st branch, user-defined exception will be throw, fault handler be enabled, afterwards the process instance will be terminated (marked as "Finished"), and its sub instance, human task instance "Task1" be terminated also.
Run on WebSphere Process Server
After process instance starts, if input id set to "000", choice will go into 1st branch, and we receive:
- Process instance be terminated, as below.
Figure 8. Explicit Termination - Process Instance Status
- Sub process instance (Human task instance in this example) be terminated also, as below.
Figure 9. Explicit Termination - Sub Instance Status
There are two patterns in this category, including:
- Transient trigger
- Persistent trigger
These two patterns are used when external signals are required to start certain tasks. They provide a way to deal with transient and persistent triggers.
This pattern requires task instance can be triggered by a signal from another part of the process or from the external environment. Most important, these triggers are transient in nature and are lost if not acted on immediately by the receiving task.
For example, should start the Handle overflow task immediately when dam capacity full signal is received. If that task can not be performed immediately, the trigger is invalid and be irrevocably lost. The full pattern detail description is located here.
The focus of this pattern is:
- Task instance can be triggered by a signal.
- The signal is transient by nature.
- If the receiving task can’t be triggered immediately, the signal will be lost.
In WID, we can use a specific business object and Event Handler to implement this pattern.
Figure 10. Transient Trigger Implementation
The specific business object (TransientTrigger) is to hold the transient trigger information, especially the trigger fire time. Seen in below picture. When trigger event comes with this business object, process will compare the current time with fire time which is held by TransientTrigger, if the current time – fire time >= 100ms, means the trigger expired, just drop the trigger; or else, trigger is active, Case 2 be executed.
Figure 11. Transient Trigger BO
This pattern requires task instance can be triggered by a signal from another part of the process or from the external environment. Most important, these triggers are persistent in form and are retained by the process until they can be acted on by the receiving task
Note: This pattern is similar with pattern Transient Trigger. Difference is that pattern Transient Trigger requires trigger is transient by nature, if receiving task can’t be triggered immediately, the signal will be lost. While this pattern requires trigger is persistent, no strict trigger time restriction for receiving task which can be initiated either immediately (if it already has received the thread of control) or at some future time.
The complete pattern detail description is here.
The focus of this pattern is:
- Task instance can be triggered by a signal.
- The signal is persistent in form.
- The receiving task can be initiated either immediately or at some future time.
In WID, we can use Event Handler to implement this pattern.
Figure 12. Persistent Trigger Implementation
After start process instance, we run into Case1, where if we get a trigger invoke (FirePerTrigger), it will enable event handler. Case2 will be executed.
In this article, we introduce five "State-based patterns", two "termination patterns" and two "trigger patterns" with relation to WID implementations. With those workflow patterns, we can add some advance control over the business process. And we approve that WID can implement all of those patterns easily and graciously.
| Description | Name | Size | Download method |
|---|---|---|---|
| PI files for this article | Part4PI.zip | 178KB | HTTP |
Information about download methods
- Learn more about the Workflow Patterns Initiative.
- Access Business
Process Management samples.
- Access WebSphere
Process Server Information Center.
Jing Wen Cui works on WebSphere Process Server testing for more than three years. She is also familiar with workflow, BPEL and related WebSphere products.




