Professional Documents
Culture Documents
Unit 17: Flow Activity
Unit 17: Flow Activity
Unit 17: Flow Activity
This is Unit #17 of the BPEL Fundamentals course. In past Units weve looked at
ActiveBPEL Designer, Workspaces and Projects, created the Process itself and
then declared our Imports, PartnerLinks and Variables and then we created
Interaction Activities in various ways. Next, we looked at the Sequence activity,
Assignments and Copies and then we studied Correlation, Scopes and Fault
Handling. In our last five units we examined Compensation, Event Handling,
Termination Handlers and the If activity, which allows us to do conditional
processing and finally at the rest of the BPEL Basic activities. In this Unit we'll look
at BPEL's Flow activity, which is the third of our container activities, after the
Sequence and the Scope.
Unit Objectives
Structured Activities
flow
forEach
if
pick
repeatUntil
scope
Process
Definition
sequence
while
Basic Activities
In this unit well look at the Flow activity, which is used for concurrent processing,
and how it uses links and transition conditions. The Flow is a structured activity and
is part of our BPEL process definition. The use of links will lead us logically to
consideration of Join conditions and dead path elimination. Weve dealt with
activities that implement program-like structures until now, but with Flow we can do
graph-like structures.
A Flow defines one or more child activities that execute concurrently, which is the
most basic use of this construct. The Flow activity also allows us to synchronize
activities, such that one activity starts when another ends. On this slide we can see
the syntax, and we see that you can optionally define one or more links, which must
have names that are unique within their scope.
All directly nested activities within a Flow are started at same time. The Flow
completes when all of its nested activities are complete.
Unit Objectives
Sequence
Flow
Invoke
Invoke
Invoke
Here we have a Sequence with a Flow that has two directly nested Invoke
activities, and a third invoke following the flow.
1.) First, the Sequence starts.
2.) Then the Flow starts.
3.) Then the two Invoke operations are executed - in parallel - as soon as
the Flow is started.
4.) If the invokes are using a request/response pattern, for example, the
Flow will complete when both Invokes have received their Replies.
5.) The third Invoke will then be fired immediately after the Flow completes.
6.) The original Sequence completes.
<sequence>
<flow>
<!-- both invokes start in parallel -->
<invoke partnerLink="Seller" ... />
<invoke partnerLink="Shipper" ... />
</flow>
<invoke partnerLink="Bank" ... />
</sequence>
Here is the syntax for the example on the previous slide. There is an outer
Sequence and then there are two Invokes each directly nested under the Flow.
Notice that there are no links between the Invokes. This means that they will
execute in parallel because they are both direct children of the Flow activity. Once
both of the Invokes in the Flow have completed, the Invoke of the bank partnerLink
will be executed. When that Invoke is complete, then the Sequence is complete.
Isolated scope
10
Isolated scopes are use to control the access to global variables, partnerLinks and
control Links, which can result in different values as each of the Scope's activities
access them. Isolating a Scope means there will be no conflicting values among
the Scopes executing activities. If the Isolated attribute is set to TRUE, then they
are executed in a defacto sequence, not in parallel. This involves the concept of
"serializability."
DEFINITION: Serializable
1.) The intuitive meaning (and mathematical definition) of "serializable" execution is
that any two successfully committed concurrent transactions will appear to have
executed strictly serially, one after the other although which one appeared to
occur first may not be predictable in advance.
2.) In databases and transaction processing, schedule (transaction history) is
serializable, has the Serializability property, if its outcome (the resulting database
state, the values of the database's data) is equal to the outcome of its transactions
executed sequentially without overlapping. Transactions are normally executed
concurrently (they overlap), because it is the most efficient way. Serializability is
considered the highest level of isolation between transactions, and plays an
essential role in concurrency control.
10
isolated="true"
isolated="true"
2*
1*
Assign
'foo' to variable x
Assign
'bar' to variable x
Invoke
Invoke
Here is a typical example using Isolated Scopes. A Variable from outside the Flow,
called x with the type string (as defined in the Standard Schema), is declared.
Then we have a Flow activity, which has two directly nested and Isolated Scopes. Both Scopes contain an Assign activity that writes to variable x, but with
different values. If x is used during the execution of the two parallel Invoke
activities, the values for x could be different in each case.
11
12
Here we see the syntax for the example seen on the previous slide. We start with a
Process-level variable declared as x of the string type. The Primary activity for
the process is the Flow. Inside the flow we have two Scopes with the Isolated
attribute set to TRUE." Each contains an Assign activity with a single Copy
Operation.
12
Unit Objectives
13
13
Graph-like structure
Control flow defined by a network
of links
flow
basic activity
basic
activity
basic activity
structured
activity
basic
activity
basic
activity
basic
activity
if
condition 1
basic
activity
14
condition 2
basic
activity
else
basic
activity
Now that we understand how a Flow works, and we understand the concept of
Isolated Scopes, we can look at two different approaches to process modeling:
Sequence vs. Flow. On the left is a typical programming-style structure, with a
single path of execution. On the right is a Graph-like structure that has a series of
links, and notice that the programming-style structure on the left does not.
Note: The programming style on the left comes from Microsoft's contribution to the
BPEL language and the graph-like structure on the right comes from the IBM
contribution to the BPEL language.
14
15
A Link connects the completion of one activity to the start of another activity. The
purpose of a link in a Flow is to make the potential execution of the Flow
conditional, i.e., based on the logic and values contained in the Link's conditions.
15
link Scenario
Invoke A
Invoke B
16
Here, by using a Link, we turn a Flow into a Sequence, in effect. Invoke A will
execute first, and upon its completion the Link will be evaluated and if its conditional
resolves to TRUE then Invoke B will be executed.
16
link Example
17
Here is the syntax for the example we saw on the previous slide. It starts with a
Flow activity, which has a Links section (one or more must be declared if a Links
section is used.) We can name a Link anything we want, but here we are calling the
first link AtoB." There are two Invokes in the Flow, each with the standard
attributes and elements. The first Invoke A is the source of the link AtoB." The
second Invoke B is the target of the link AtoB." When declaring a Link, the
Source element and Target element define where the link begins and ends and are
used to control the flow of execution within the enclosing activity.
17
link Semantics
18
Here are the semantics of our Links. Links only apply to the Flow activity. Links
must be uniquely named within the Flow. The purpose of a link is to control the
order of execution. Each link must have exactly one source and exactly one target.
However, mutliple links can leave and enter a single source or target, provided that
they are coming from or going to separate and distinct activities. The target activity
of a Link will not commence until the Source activity of the link is complete.
18
19
So, how do we Link activities when working in the Designer? Recall that Links can
only be used in a Flow activity. Simply select the activities in the desired execution
order, and then use the Right Mouse context menu and select Link Activities.
19
20
20
Unit Objectives
21
21
22
Transition conditions can only apply to a Link within a Flow activity. These
conditions determine whether or not the Link is traversed, and the condition
expression must evaluate to a boolean value to be valid. Here the transition
condition is for the Source end of a Link, and can therefore be called an outbound
link condition.
22
23
Links within a Flow activity do not have to have explicit transition conditions. If they
dont, they have an implicit transition condition whose default value is TRUE. A
property value can be used in a transition condition, and we are allowed ot use the
$variable syntax style in our transition conditions.
23
Invoke A
Invoke B
Invoke C
Invoke D
24
Here is a typical Transition condition scenario. The Flow activity starts and Invoke
A complete its actions. Once the Invocation of A is complete, we can evaluate
order total to fire either Invocation B or Invocation C. Based on the "order total"
value, one Invoke (i.e., B or C) or the other is chosen, fired and completed, followed
by the Invocation of D." Note that whichever one of B or C is not traversed will
never be traversed.
24
Here is the syntax for the transition condition example we saw on the previous slide.
The declarations for the Links are first, and here we have four of them: AtoB,
AtoC, BtoD, CtoD. The first invoke, A, is the source for two links: AtoB and
AtoC. Each of these two Links has a transition condition based on the value of
$order.ordTotal. The next invoke, B, is the source for one (BtoD), and a target
for one (AtoB). The next invoke, C, is the source for one (CtoD), and the target for
one (AtoC). And finally, the last invoke D is the target for two links: BtoD and
CtoD.
25
Fork Activity
Source activity that has more than one outgoing link
All links whose transition conditions evaluate to true
will be followed
Concurrent Processing
Achieved whenever two or more outgoing links
evaluate with a true transition condition
Activity
Activity BB
Activity
Activity A
A
Activity
Activity C
C
26
The Fork activity is conceptual only. There is no actual Fork activity on the
pallette. A Fork activity is any activity that has more than one outgoing link. If two
(or more) transition conditions that each evaluate to true, then all of the target
activities at the end of those Links are executed concurrently.
26
Unit Objectives
27
27
Join Activity
Conceptual term identifying a target activity that has
more than one incoming link
Does not start until the status of all its incoming links
have been evaluated
Synchronization
Achieved whenever two or more incoming links
evaluate with a true link status
Activity
Activity BB
Activity
Activity D
D
Activity
Activity C
C
28
Now we look at the Join activity. Much like the Fork activity, a "Join activity" is a
conceptual term. This term applies when one activity is the target for more than one
link. Note, of course, that there is no actual Join activity, but there is a join
condition attribute which like transition conditions - must evaluate to a Boolean
value. For example, here activity D has two inbound links, making it a Join
activity. Activity D wont be executed until all incoming transition conditions to the
activity are evaluated. Because of this behavior, joining two paths is often called
synchronization.
28
29
Join conditions exist to specify whether one or more paths will reach a target
activity. This is determined by the status of all of the activity's incoming links. Each
Link evaluates to True, False or Unset and, because these resolve to Booleans,
we can also use OR and AND in our expressions. Note that if the status of a Join
Condition is not explicitly defined, it is an implicit join condition. The status of at
least one incoming link to a given activity MUST be true.
29
true
false
30
30
Invoke A
Invoke B
Invoke C
true
true
joinCondition
Invoke D
31
Here is a typical Join condition scenario. We have a Flow activity, with an Invoke
"A" as its primary activity. Invoke "A" is the source of two links, one to Invoke "B"
and one to Invoke "C." Each of the Invokes "B" and "C" are the source for links that
go to the target, Invoke "D." In this case, we wont execute Invoke D unless both
Invoke B and Invoke C execute successfully.
31
32
Here is the syntax for the previous example. We are inside a Flow, and Invoke "A"
is source of two links: AtoB and AtoC. Invoke B is the source of one link and the
target of one link, as is Invoke C. Invoke D is a target of two links and has a join
condition to evaluate the status of those links. In this case, both BtoD and CtoD
must evaluate to TRUE for Invoke D to execute.
32
33
Now let's take a look at how to use the Join condition builder when working in the
Designer. First, select the target activity, click on "Show Advanced Properties," and
then create the expression using the Join Condition Builder. (Note: you must click
in the Join Conditions Value field in order to make the ellipsis icon visible and
enabled.) Once you are in the Join Condition Builder dialog, you must first choose
to use either the default expression language or select another one. The Join
Condition itself is constructed using the data in the three panes: Links (which shows
only those in scope), Functions and Operators. We can double-click on a Link to
add it to the Join Condition, and then follow that with whatever Functions and
Operators are appropriate to construct our Join Condition. Note that you can also
edit the Join Condition's textfield manually, if you wish to do so.
33
34
Next we'll look at the "Suppress Join Failure" setting. This is set at the scope level,
but can be overridden. When a join condition evaluates to False a joinFailure fault
is thrown. We can either handle the fault or suppress it using the attribute
suppressJoinFailure. (Note: if you have one link and its condition evaluates to
False, it will always throw a joinFailure fault.) "SuppressJoinFailure" is a standard
attribute, and can be associated with any basic or structured BPEL activity. If this
value is not explicitly set, it is automatically inherited from its parent container, which
can be a scope, sequence or process, for example.
34
Invoke A
Invoke B
Invoke C
Invoke D
35
35
36
Here is the syntax for the "SuppressJoinCondition" example on the previous slide.
We are inside a process with the value set to "no" and then we are inside a Flow
where the value is set to "yes." Invoke A has two links, to Invokes B and C, with the
transition conditions and target activities shown. There are also links from both
Invokes B and C to Invoke D.
36
Unit Objectives
37
37
38
Next, we'll take a look at Dead Path Elimination. This happens at execution time, as
the system evaluates the flow of execution and checks to see if there are any paths
wont be traversed, meaning that there are activities that will not indeed cannot be traversed for execution. The system automatically fills in the Link status to the
value of False, as appropriate.
38
Invoke A
Invoke B
Invoke C
Invoke D
Invoke E
39
Let's examine the same scenario, but with some new links. If the value of order
total is less than or equal to 500, the Path on the right side - a-c-d-e - will never be
executed during this run.
39
Invoke A
Invoke B
Invoke C
false
Automatically
propagates a false
link status
true
Invoke D
false
Invoke E
40
The system knows this and automatically propagates a False status to all the Links
down the entire Dead path.
40
41
The next Lab in the BPEL Fundamentals class is Lab #12. (Note: This is lab #4 if
you are taking BPEL Fundamentals II.) In this lab we will add a Flow activity after
the initial Receive activity in order to perform an Audit and a Credit Check
concurrently. We'll use the concepts we just learned to re-order the remaining
Order Process by adding Link transitions where needed. Then, we'll add two Global
Fault handlers, add a Throw activity and finally, we'll use the Empty Activity as a
placeholder.
41
Unit Summary
42
42