BPMN Conditions and Other Gateways

Lab #1 – Page 1 of 8 - ActiveVOS Fundamentals
ActiveVOS Fundamentals
Lab #7
BPMN Conditions and Other Gateways
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 2 of 8 - ActiveVOS Fundamentals
Lab Plan
In previous labs we have examined two of the BPMN gateways. In this lab we will learn
the rest of the BPMN Gateways and also how to control execution using Links and Link
Transition Conditions. The link logic and the transition conditions can be written in
XPath or in any of the other supported expression languages (XQuery and Jscript).
Once we are familiar with all of the gateways and we know how to use links, we can start
designing our own processes, based on requirements that will be provided.
Lab Prep
Before starting make sure that:
- you have completed Labs 1-6.
Lab Steps
Gateway Review
In Lab #4 we used the Exclusive Gateway (exactly one of two or more outbound links
are traversed) implemented in the Control Flow tray of the palette as either the
Conditional Pattern or the Repeat Pattern.
In the same lab we used a Parallel Gateway (all outbound links are always traversed
concurrently and unconditionally) implemented in the Control Flow tray as a Fork
Pattern.
Other BPMN Gateways
In this lab we will look at three other gateways: The Event-based gateway
(implemented in BPEL as a Pick activity), the Inclusive Gateway and the Complex
Gateway.
Event-based Gateways
1. Open the ActiveVOS_7_GatewaysAndLinks project. Open the OtherGateways
process and examine it until you understand how it works.
2. When we execute the Create a Sales Order task we are invoking a partner service
that will fulfill the order the customer has sent us. They send back a synchronous
response to complete the invoke and then, while they fulfill the order, we wait for
them to tell us when the order is complete. The intermediate catch activity we see
immediately after the Create a Sales Order task waits for the asynchronous, inbound
message they will send us, known as a callback.
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 3 of 8 - ActiveVOS Fundamentals
3. As the process is currently defined, the callback could come in a few seconds or it
could come back days or weeks later. If this is what is appropriate, that is fine, but
normally we want to wait a specific amount of time and then do something else if the
message has not arrived. Putting a timer on the receipt of a message is a common
use for the Event-based Gateway, called a Pick in BPEL. Go to the palette and
drag an Event-based gateway from the Gateways tray and drop it immediately
before the callback. Change the gateway name to Wait for Callback.
4. Delete the original callback’s catch and then drag the Acknowledge Callback throw
(i.e., the reply) event into the sequence that is nested under the On Message
element of the gateway.
5. Change the text of the On Message to Receive Callback. Change the text on the
Timer side to 30 Minute Alarm.
6. Go to the Task tray of the palette and drop a Suspend Task into the sequence under
the Alarm and call it Suspend Process – Wait for Admin. When you are done this
portion of the process will look like the diagram on the right.
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 4 of 8 - ActiveVOS Fundamentals
Now that an Event-based gateway has replaced the original Catch, the process will
execute until it gets to the gateway, where it will wait for the callback. If it does not
arrive in 30 minutes the Alarm will be triggered. The Event-based gateway waits
until the first of the defined set of events is triggered, in this case either the arrival of
the callback or the triggering of the alarm. Once one of the defined events occurs, all
other events are immediately disabled. If the callback arrives after the alarm is
triggered, the callback is discarded. If the callback arrives first, the alarm is disabled.
Inclusive Gateways
We will continue working in the OtherGateways process file. After we have received the
callback, we will finish processing the order. We need to ship the order if it is complete,
send a gift if the customer is new and arrange a follow-up visit if the order is over $100K.
These three tasks are independent of one another and each requires a yes/no condition.
To implement this we can use an Inclusive Gateway. Recall that Inclusive Gateways
can have one or more outbound paths, and all paths whose conditions evaluate to true
will be executed. Our new gateway will have three outbound links.
1.
Drag an Inclusive Gateway onto the canvas and drop it at the end of the sequence.
Delete the End event that preceeds it. Because of the way the structured areas
work in ActiveVOS (i.e., linear, single path execution only within sequences)
gateways are easier to work with if they are the first or the last item in a sequence.
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 5 of 8 - ActiveVOS Fundamentals
2. Add three Service Tasks below the sequence and use the right-mouse menu to link
them to the new gateway. The source is where the link starts and the target is where
the link ends. Call the services Ship Order, Send Gift and Arrange Follow-up.
3. Drop another Inclusive Gateway after the three new tasks and connect each task to
this second gateway. This gateway will wait for all of its inbound links to resolve to
True, False or Dead Path before continuing down the rest of the sequence. It works
as a synchronization mechanism for all of the parallel paths, making sure that only
one execution token exits the second gateway. Your process will look like this:
4. Now that we have the structure in place, we need to add logic to the links. Select the
link that connects from the first gateway to Ship Order. When it is selected, use the
Property sheet to set the label to Order is Complete. Next, create a new Boolean
variable called OrderComplete. Set the Transition Condition to $OrderComplete =
true(). You can set the condition by clicking on the ellipsis button that is to the right
of the Transition Condition field. This will open the Transition Condition Builder.
5. The second path is traversed if the customer is new. For this link’s logic we will
create a new variable called NewCustomer of the boolean type. If this value is true,
we traverse the link and execute the target service task. Label the link New
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 6 of 8 - ActiveVOS Fundamentals
Customer and add a transition condition that checks if the value of the
NewCustomer boolean variable is true.
6. The third path is traversed if the Total Cost of the order was for more than $100K in
products. Set the label to Order Over $100K and create a transition condition that
checks if the value of the OrderTotal element in the SubmitOrderRequest variable is
over the dollar limit. The Order Total element is defined in the schema as a decimal
type that has 8 digits or less and extends two places to the right of the decimal point.
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 7 of 8 - ActiveVOS Fundamentals
Complex Gateways
1. Open the ComplexGateway process. This process receives a document for review.
It must be approved by at least 2 out of 3 reviewers before we can proceed. This N
out of M scenario is a common use case for the complex gateway. This gateway
type is used for what is sometimes called a voting pattern or a discriminator pattern.
Note that this pattern can be implemented more intuitively with a Multi-Instance
activity that uses the Completion Condition attribute, or with the use of two or more
simpler gateways. We know of no use case that requires a complex gateway. Many
organizations have Best Practices that discourage the use of the Complex gateway.
If used, proper labeling of artifacts and the use of annotations can help to document
and explain the behavior of the complex gateway.
2. Complex Gateways use a combination of Transition Conditions on the links and
Join Conditions on the gateway. Transition Conditions are the logical expressions
defined for the link itself, which control traversal of the link during execution. Join
Conditions allow you to create expressions which are based on the values of two or
more of the inbound links themselves, i.e., each link evaluates to either True or
False. In this case, we have to create a Join Condition that looks for two out of three
links to be true.
Applying Your Skills
Now that we have examined the palette and the artifacts of the BPMN language, we can
start applying these skills to design a process. To complete this part of the lab you will
build a basic process, based on the requirements given below. Focus on the BPMN
design, the logic of the process, the use of descriptive noun-verb names for activities
and events and the labeling of the diagram to make it self-documenting. You do not
have to create the actual expressions in the gateways and other constructs, but you
should label them in a way that the logic that would be applied is clear to the reader.
Because this is a design exercise, not all answers will be the same.
Copyright © 2004-2011 Active Endpoints, Inc.
Lab #1 – Page 8 of 8 - ActiveVOS Fundamentals
An Online Auction Process:
The process begins when an item is submitted for auction.
Once submitted the item must be processed by the Admin dept.
Once processed, the item will be checked to see if it is a restricted item.
If it is restricted, we notify the seller and end the process.
If it is not restricted, we proceed to the auction.
Auctions begin at 9AM each day.
The item can be withdrawn at any time before the auction begins.
Once the auction begins the item will either be sold or it will not be sold.
When the auction ends, the auction service will tell us whether it was sold or not.
If the item was sold it will be shipped to the buyer.
If the item was sold, the customer must be notified by email.
If the item was not sold we must notify the seller.
If the item was not sold, the seller can withdraw the item or re-submit it to be auctioned
again.
Copyright © 2004-2011 Active Endpoints, Inc.