Business processes are an integral part of a Service-Oriented Architecture (SOA) and are created using standard XML definitions BPMN and BPEL. In this section, you'll learn more about how business processes fit into the SOA model, and about the two business process XML standards (BPMN and BPEL) and their relationship.
An SOA comprises several services that are accessible and can interact with each other over the Internet. SOA is easy to maintain and deploy since it's done one service at a time. Business processes easily fit into this model, having their own service endpoint, as defined by WSDL that can interact and exchange data with other services over the Internet.
In the next two sections, you'll learn about the business-process modeling and execution formats: BPMN and BPEL.
BPMN essentially defines the business process's tasks, entities, and the arcs between them (the flow among tasks) in XML format. BPMN is the language that the models created using the Eclipse STP BPMN Modeler are converted into. Perhaps a graphical representation of a business process would best explain this concept.
Figure 1. Model of a business process
The image shows a single horizontal flow of a business process cut into three slices, stacked vertically and in order. In Figure 1, the model of a business process was created using the Eclipse STP BPMN Modeler, which you'll use later. You can see where the process starts with the empty circle on the left, with the flow being guided to the right using arrows/arcs, ultimately ending with the empty circle on the right.
BPMN is simply an XML format describing, for example, the model shown in Figure 1. It
contains vertices that correspond to nodes and
sequenceEdges that correspond to
arrows/arcs. Take a look at an example of each in Listing 1.
Listing 1. Sample vertices and
<vertices xmi:type="bpmn:Activity" xmi:id="_OioEMZ-jEdyW35YU1b0yXQ" iD="_OioEMJ-jEdyW35YU1b0yXQ" outgoingEdges="_PBxeUZ-jEdyW35YU1b0yXQ" incomingEdges="_Pe-XsZ-jEdyW35YU1b0yXQ _PuxHMZ-jEdyW35YU1b0yXQ" name="orderCheck2" activityType="GatewayDataBasedExclusive" looping="false"/> <sequenceEdges xmi:type="bpmn:SequenceEdge" xmi:id="_r1A1oZ-iEdyW35YU1b0yXQ" iD="_r1A1oJ-iEdyW35YU1b0yXQ" source="_mxgfgZ-iEdyW35YU1b0yXQ" target="_exzeA5-iEdyW35YU1b0yXQ"/>
Vertices are essentially nodes or tasks, shown graphically in Figure 1 as
circles, diamonds and squares. In Listing 1, you can see that they have identifiers, as
well as a list of outgoing and incoming edges. Identifiers simply give vertices an ID
that can be referenced as sources and targets of
sequenceEdges (shown in Figure 1 as directional arrows going from
vertice to vertice). The important information in each
sequenceEdges is the source and target attributes that specify the
source vertices and the destination vertices. Please note that this file format is not
executable on Apache ODE as it's only the model of a business process, so you'll use
the Eclipse ATL project and an open source tool written by BABEL to convert the model into an executable.
As the name implies, BPEL is executable on process engines like Apache Orchestration Director Engine (ODE).
The difference between BPEL and BPMN is that BPEL is more structured, being an
executable language by definition. Instead of vertices and
sequenceEdges, a BPEL XML file contains sequences of instructions
that include invoking a Web service operation and statements like
while loops that can execute a sequence of code again and again if
its condition remains true (see the
</condition> tags after the opening
<while> tag in Listing 2) and
if else-if else statements.
In Figure 1 (slice 2) there is one instance where an arc goes backwards. That is how
you code a
while loop using the BPMN Modeler. There, you'll
see the two vertices labeled while1 and while2 that facilitate the correct branching of
processes (while1 combines two input edges into a single output edge, and while2 takes
one input edge and splits it into two output edges). The condition of the
while loop is defined by
while_ok, and if
it remains true, the
shippingEstimator task will be performed
again and again. When the same condition is no longer true, execution breaks and goes to the checkout task.
To see how the above model of a
while loop is then
represented in BPEL, take a peek at Listing 2.
Listing 2. Example
whilestatement in BPEL
<while> <condition> getVariableProperty(shippingEstimator_data_in,Message)="true" </condition> <invoke name="shippingEstimator" partnerLink="mybiz_flow_servicePartnerLink" portType="sns:mybiz_flow_servicePortType" operation="shippingEstimator" inputVariable="shippingEstimator_data_in" outputVariable="shippingEstimator_data_out" /> <assign name="postShipping"> <copy> <from variable="shippingEstimator_data_out" part="Message" /> <to variable="shippingEstimator_data_in" part="Message"/> </copy> </assign> </while>
Here, you can see the
while loop model shown in Figure 1
(slice 2) coded in BPEL format, which has the same image of
while loops in other programming languages, except this one is
defined using XML. You'll see this snippet of code again later, where you'll also learn
about more about other BPEL constructs.
Note that the above BPEL is not ready for deployment alone, since it requires a deployment descriptor and WSDL to define the service endpoints for your business process, which you'll also learn to create for an error-free deployment to Apache ODE.
To sum up: BPMN XML defines a graphical model of your business process with nodes and
edges, and BPEL defines an executable model of your business process with executable
while loops and
if statements, and statements that call operations on existing Web services.
The business process you'll model is a simple flow of adding a toy to a shopping cart.
Users will have the option to use a shipping estimator (the
while loop you see in Listing 2), check out, and place an order that
can be rejected or accepted, with an accepted order sending an invoice to the customer and placing the order in a shipping queue.
Next, you'll install all the required tools so you can quickly dive into the development of your business process.