Business State Machine How to
Websphere Integration Developer v612
Business State Machine
How to generate a State Machine implementation
How to add a state
How to transition from one state to another state
How to add a variable-State Machine
How to setup the initial state
How to add an operation to a transition
How to add an action to a transition
How to add an Entry element to a State
How to add a condition to a transition
How to add a Visual Snippet - State Machine
How to add a correlation set - State Machine
How to use the business state machine editor to create a business process component (including events, guards, actions and correlation sets)
Business State Machine Editor example This is a business state machine editor window with a completed business state machine. Receive activity A receive activity is an entry point to a process; it is the point where the process starts or continues. Using the Business State Machine Editor Here are some of the functions you can do with the business state machine editor. How to generate a State Machine implementation How to add a variable-State Machine How to setup the initial state How to add an operation to a transition How to add an action to a transition How to add an Entry element to a State How to add a condition to a transition
Related links
How to add a state
How to transition from one state to another state
How to generate a state machine implementation
Generated state machine implementation
WID generates a basic state machine implementation that you can modify as required.
As you can see, the related partners (Interfaces and Reference) are defined based on the Assembly diagram, the wiring done, and the interfaces/references defined for each component.
This basic state machine implementation was generated by following the steps below.
| Assembly Diagram ProcessOrder interface (ProcessOrder component) |
Step 1 Generate State Machine implementation
In the Assembly Diagram editor, right-click the component you want to implement and select Generate Implementation > State Machine. |
|
Step 2 | |
How to add a state
Add a state
| |
New state added
A new state (OrderBeingShipped) has been added.
| |
How to add a correlation set - State Machine
Add a correlation set
| |
Create Correlation Property
| |
Select Data Type
| |
Create an Alias
Click New button (next to Aliases) | |
Select Property Alias for placeOrder input
| |
Create another Correlation property
A correlation property has been added to placeOrder.
Create another correlation property for orderShipped. To do this, click New button. | |
Select Property Alias for orderShipped input
| |
Correlation Property set
Correlation Property has been set for placeOrder and orderShipped.
| |
Correlation set has been setup
The orderNumber attribute of the Order business object used as input to either operation is now an alias for the OrderNumber correlation. | |
How to add an Action to a transition
Variables to define |
|
Add an Action
Right-click the transition between WaitingForOrder and CustomerBeingChecked and select Add > Action.
Rename the action to Print info and set variables. | |
Configure the Action
Save the project. | |
How to add a Condition to a transition
Adding Conditions
We will add conditions on the two transitions coming coming from CustomerBeingChecked (GoodCustomer and BadCustomer). | |
What is a Condition?
When a state (i.e CustomerBeingChecked) has transition choices (i.e it can transition to one state or another state), you must have procedures in place to control which transition to follow. Otherwise, WID will flag this as an error (This transition will not occur because another transition will always occur) as is the case with the state machine (right column) which currently has no conditions in place.
For example, if it is a good customer, you ship the order (transition to OrderBeingShipped). Else, you reject the order (transition to OrderComplete).
To do this, you must set a condition to guard the transition. | |
Variables to define | isCustomerOK type boolean |
Add a Condition for Good Customer
First define a variable (isCustomerOK of type boolean).
Right-click the transition between CustomerBeingChecked and OrderBeingShipped and select Add > Condition.
Rename the condition to GoodCustomer. | |
Configure the Condition
Save the project.
Notice that an error now points to the un-guarded transition.
In the same manner, put a condition on the unguarded transition (the transition between CustomerBeingChecked and OrderComplete) to fix the new error. | |
Conditions (Guards) in place
Both transitions are now conditional (guarded).
For example, if isCustomerOK is true, the GoodCustomer transition will be followed.
If false, the BadCustomer transition will be followed.
Note: The BadCustomer visua snippet inverts the the result of the return. | |
How to add a Visual Snippet - State Machine
How to add a Visual Snippet
In the state machine editor, do the following:
| |
Drag a variable
Select isCustomerOK and drag/drop it to the visual snippet editor canvas. | |
Add Return
Right-click on the visual snippet editor canvas and select Add > Return. | |
Drop Return
Drop Return under the isCustomerOK visual snippet. | |
Connect Visual Snippets
Snag the link coming out of isCustomerOK and drag it to Return. | |
Visual Snippet is complete
| |
How to add an operation to a transition
Add an operation
In the State Machine editor, right-click a transition and select Add > Operation.
Note: An Operation can only be added to a Transition. | |
Select the interface/operation
| |
An Operation is added
An Operation (i.e placeOrder) is added.
| |
How to setup the initial state
The initial state
The transition from the main state machine's initial state must have an operation. The error icon indicates that an operation is not currently defined for the initial state transition.
Note: The initial state is the the first state and starting point of any state machine. It is where things begin.
An operation enters the machine, and attempts to initiate a move to the next logical state.
| |
Add an operation
Right-click the transition from the initial state and select Add > Operation. | |
Select the interface/operation
Note: The ProcessOrder state machine uses the ProcessOrder interface.
| Assembly Diagram ProcessOrder interface (ProcessOrder component) |
The Initial State transition has been setup properly
| |
How to transition from one state to another state
Select a "source" state
Right-click the 'source' state (i.e CustomerBeingChecked) and select Add > Transition.
Note: A transition connects one state to another in a state machine. It transitions execution from one state to the next by recognizing the triggering event (operation), evaluating the conditions necessary for execution to flow through it, and determining what actions can occur should execution be allowed.
| |
Connect the "source" state to a "target" state
Drag and drop the transition from the "source" state (i.e CustomerBeingChecked) to a "target" state (i.e OrderBeingShipped).
| |
A connection has been made
A connection (transition) has been made from CustomerBeingChecked to OrderBeingShipped. | |
How to add a variable-State Machine
Add a Variable
Click the + in the Variables section. | |
Set the data type
| |
Variable defined
A new variable (myOrder) is defined. | |
How to add an Entry Element to a State
Add an Entry
Right-click the CustomerBeingChecked state and select Add > Entry.
Rename the default entry name to Check Customer. | |
Configure the Entry
Save the project.
Configure the output
Save the project.
| |
No comments:
Post a Comment