Web Services
Model Your Business Processes Using BPML
Digg This!
This article introduces the Business Process Modeling Language, a standard specification to model business processes. To illustrate the elements of BPML, I'll use a simple example that handles purchase orders.
BPML is an XML metalanguage for business process modeling. A standard published by Business Process Management Initiative (BPMI), it provides a universal way to describe business processes in organizations. Business processes modeled using BPML can be deployed and executed on any BPML-compliant Business Process Management System (BPMS).
BPML Fundamentals
Process
Process is the core concept of BPML. Key components of a process include:
- Execution of a set of activities
- Interaction with participants by exchanging messages
- Predefined rules to determine the flow of the execution
- Schedules to govern the start and completion of the execution
- Processing of data by holding the internal data that can be accessed by all its activities
I'll use a simple handlePurchaseOrder process to illustrate how to model a process using BPML. The process contains the following steps:
1. At startup the process will wait for the message "purchase order".
2. When it receives a purchase order, the process will check whether it's an existing customer, and will create a customer account if it's a new customer.
3. The process checks the inventory system to see whether there's enough inventory to fulfill the order.
4. The process sends a shipping bid to all the carriers it contracts. It sets a predefined price, and will accept the first bid that meets the price criterion.
5. The process schedules an order delivery with the selected carrier.
6. The process sends a shipping notification to the customer.
First, we need to define our process:
<process name="handlePurchaseOrder">
...
</process>
We'll keep adding elements as we go on.
Activities
In BPML there are three types of activities: simple, complex, and process. A process can have one and only one top-level activity.
A simple activity is an atomic action that contains no other activity. It performs a task that involves communication with participants. Following is a list of simple activities defined in BPML:
Consume: An activity that waits and consumes a message. It will wait until a suitable message is available.
Produce: An activity that produces and sends a message to a participant.
Operation: A synchronous request/response interaction that exchanges messages with a participant. It has two types, invoking and implementing. Invoking produces an outgoing message (a request) to a participant and consumes an incoming message (a response). Implementing consumes an incoming message (a request) and produces an outgoing message (a response).
Empty: An activity used to describe an action that requires human interaction, such as setting up a meeting or obtaining a signature from a manager.
Exception: An activity used to indicate that an error occurs during the execution. Every exception has an exception code.
Next, I'm going to add a few simple activities to our process:
In Step 1 we'll define a Consume that waits for incoming orders with a message named "purchaseOrder".
<consume name="waitingForOrder">
<input message="purchaseOrder"/>
</consume>
In Step 3 we'll define an Operation (invoking) that sends out a checking inventory request to the inventory system and waits for the checking inventory response. This is an invoking operation in that the output appears before the input. The order of input and output appearing in an operation is how we differentiate invoking and implementing.
<operation>
<participant select=
"inventorySystem"/>
<output message=
"checkInventoryRequest"/>
<input message=
"checkInventoryResponse"/>
</operation>
In Step 4 we'll define a Produce that sends out a ship request to all the carriers and a Consume that waits for carriers to send their responses.
<produce name="sendingBidToCarriers">
<participant select="carriers"/>
<output message="shippingRequest"/>
</produce>
<consume name="waitingForCarrier">
<input message="shippingResponse"/>
</consume>
In Step 5 we'll define a Produce that sends out an order delivery schedule to the selected carrier.
<produce ="sendingShippingOrder">
<participant select=
"shippingResponse/carrier"/>
<output message="shippingOrder"/>
</produce>
In Step 6 we'll define a Produce that sends out a shipping notification to the customer.
<produce ="sendingNotification">
<participant select=
"purchaseOrder/customer"/>
<output message=
"customerNotification"/>
</produce>
A complex activity is used to composite one or more activities. Different complex activities provide different flows of executions. A complex activity completes when all its containing activities have completed. Following is a list of complex activities defined in BPML:
- Sequence: Contains a list of activities that are executed in sequence.
- All: Contains a list of activities that can be executed in parallel.
- Switch: Contains a list of activities of which zero or more will be executed, depending on the condition or the rule defined for each individual activity.
- Choice: Contains a list of paths, each with a set of activities. Only one of the paths will be executed, depending on the incoming message.
- Foreach: Contains a list of activities that are repeated with different sets of process data.
For our handlePurchaseOrder process we'll define a Sequence and put all the activities to execute in the Sequence. This will be the top-level activity for our process. Within the Sequence we'll put sending delivery schedule and sending customer notification in an All because they're independent and can be executed in parallel. We'll use a Switch for Step 2 of the process to create a new customer account in the Customer Account Database if it is a new customer (see Listing 1).
The third type of activity is process activity, which affects only process and process data, but doesn't interact with any participant. Following is a list of process activities defined in BPML:
- Spawn: Spawns a nested child process under the current process
- Join: Waits for child process to finish
- Complete: Causes the current process to complete immediately
- Repeat: Repeats an activity that has executed before
- Assign: Transforms data between messages and process data
- Release: Removes data from the process data
Participant
Any entity that a process communicates is defined as a participant. Participants can be business applications (e.g., ERP, CRM), customers, partners, and other processes. They can be either static or dynamic. Static participant is defined in the process and is referenced by activities in the process. Dynamic participant is retrieved from process data using XPath expression. In our example we define inventorySystem and customerAccountDatabase as static participants; they are referenced by Operation checkingInventory and createNewAccount, respectively. In Produce sendingShippingOrder the participant is the carrier retrieved from shippingResponse. In Produce sendingNotification the participant is the customer retrieved from purchaseOrder.
Message
Messages are used to exchange information between a process and its participants. All messages are in XML format, and a schema is used to define the format. Upon receiving a message, an activity can use rules to decide whether it will consume the message. Consumed messages are transformed into process data using assignment. XPath is used to retrieve and transform messages.
Listing 2 is the XML schema for the message "purchaseOrder". We need to define the schema for every message we use.
Here is the assignment that retrieves the product information portion from the purchaseOrder message and transforms it into a new process data element pendingOrder:
<assign target="pendingOrder">
select="purchaseOrder/product"/>
</assign>
Rules can be set to decide whether to consume a particular message. In our example assume that we'll accept the first carrier whose bid is less than $50.
<consume ="waitingForCarrier" >
<input message="shippingResponse">
<rule condition=
"shippingResponse/charge <= 50"/>
</input>
</consume>
Scheduling
Schedule is used to set the start time and time limit of an activity. Schedule can be an absolute time or a relative time that references the start or the end of another activity. For our Consume "waitingForCarrier" we set a time limit of 6 hours so that the bid will stop in 6 hours. If there is no bid less than $50 when time expires, a bpml:timeout exception will be thrown.
<consume ="waitingForCarrier" >
<completeBy duration="PT6H"/>
<input message="shippingResponse">
<rule condition=
"shippingResponse/charge <= 50"/>
</input>
</consume>
PT6H is an XPath expression that represents a duration of 6 hours.
Exception
In BPML exceptions can be handled for complex activities through the use of onException. One onException can be defined to cover all exceptions. In this case there will be no exception code associated with the onException. You can also define multiple onExceptions to handle different types of exceptions by specifying exception codes for each onException.
For our Consume "waitingForBid" we set a time limit; hence, a bpml:timeout exception will occur if there is no acceptable bid. To handle the exception, we define an onException that will send an alert message to the manager (see Listing 3).
Transaction
Transaction is an indivisible unit of work that comprises several operations, all or none of which must be performed to preserve integrity. There are two transaction models in BPML, Coordinated and Extended. Coordinated transaction is the ACID transaction in which activities within the transaction must either all complete or all abort; it's used for short-lived activities. Extended transaction is the Saga transaction in which all activities will complete - in the event of failure, compensating activities will be executed; it's used for long-lived activities. Both models support transaction types - supported, required, new, nested, and none.
Now let's define a transaction for our All activity so that sending shipping order and sending customer notification will complete or both will abort (see Listing 4).
Figure 1 is a screenshot of our sample process modeled using DCH Systems' BPMS.
BPML and BPMS
BPMS is a system that abstracts and executes business processes. Usually a BPMS provides the following features:
- Modeling: Provides a visual tool (GUI) for business process modeling
- Automation: Executes processes in an automated fashion
- Monitoring: Provides runtime data and statistics about process execution
A BPML-compliant BPMS is a system that models processes in BPML and can import a BPML document and execute with minimal configuration.
* * *
This article introduces BPML and its core concepts. You've seen from the example how to use BPML components to model business processes.
References
This article is based on the BPML working draft 4.0 dated March 8, 2001. The draft was being revised at the time this article was written.
For more information on BMPL:
www.bpmi.org
For more information on XPath:
www.w3.org/TR/xpath
About Shannon MaShannon Ma is a senior software developer specialized
in J2EE, Web Services and BPM. He is currently
working at AVAO, a software company that provides a
robust, comprehensive and portable business process
management system (BPMS).