Wednesday 9 November 2011

Lesson04-Human Workflow

image
Continuing from earlier Mediator example, lets extend our use-case to include .
MyDel handles two types of orders: Normal and Express. Normal orders are processed only after order items arrive in the Depot. Depot manager then logs into Workflow and releases the order to be sent for further processing in Order Management system. However, Express orders are directly sent for processing into Order Management system.
In this example, we are going to route orders through an Order Router that will route Express and Normal orders to Order Management service and Human Workflow respectively. Depot Manager logs into Workflow system to release order for the goods received in Depot. Released orders will be written to Order Management system.
Please use the Human Workflow JDeveloper Template if you want to implement this project on your own. Complete JDeveloper project is also available from Downloads section.
In previous Mediator Example, the process we built is shown below:
Mediator Example
Drag and drop a Mediator component from Component Palette on to Components lane of composite.xml. Name it OrderRouter and select “Define Interface Later” template.
orafmwschool_hwflow02
Delete the link between OrderFTPABCS and OrderABCS as shown below.
orafmwschool_hwflow04
orafmwschool_hwflow06 orafmwschool_hwflow05
Similarly, delete the link between OrderWSClientService and OrderABCS.
orafmwschool_hwflow08
Connect OrderWSClientService and OrderRouter.
orafmwschool_hwflow10
Connect OrderFTPABCS and OrderRouter. Then connect OrderRouter and Order ABCS.
orafmwschool_hwflow13
Connect OrderFTPABCS and OrderRouter. Then connect OrderRouter and OrderABCS. So far, we introduced OrderRouter before OrderABCS in order to branch request to Workflow where appropriate.
Lets proceed with workflow creation. Drag and drop “Human Task” component from Component Palette. Name it “OrderApprovalTask”. Specify “http://orafmwschool.com/training/workflow/OrderApprovalTask” as Namespace.
orafmwschool_hwflow16
In General section, enter details as shown below.
orafmwschool_hwflow19
In Data section, select OrderDetailsRequest element as shown below.
orafmwschool_hwflow20  orafmwschool_hwflow21orafmwschool_hwflow22
In Assignment section, double click on <Edit Participant> and enter weblogic user as shown below.
orafmwschool_hwflow24  orafmwschool_hwflow25
orafmwschool_hwflow26
This completes the creation of Human Task. We need to link this to BPEL process in order to execute it. Lets drag and drop a BPEL process from Component Palette. Enter values as shown below. Input and Output variables can be chosen from Type Explorer by clicking on magnifying icon.
orafmwschool_hwflow29
Double click on ApprovalProcess to open BPEL design window. Drag and drop a “Human Task” component as shown below.
orafmwschool_hwflow31
Select OrderApprovalTask in Task Definition field.
orafmwschool_hwflow32
Select OrderDetailsRequest as Task Parameter.
orafmwschool_hwflow34
This will create OrderApprovalTask_1 component in BPEL that looks like below:
orafmwschool_hwflow66
OrderApprovalTask _1 can have three outcomes: NO, YES and Others. We need to invoke OrderABCS when outcome is YES. In two other cases, we will let the workflow return without performing additional tasks.
Lets drag and drop an invoke activity in “Task outcome is YES” branch and name is Invoke_OrderABCS. Select OrderABCS as Partner Link and its ReadOrder as an Operation. Also, click on “+” sign to create automatic input and output variables.
orafmwschool_hwflow67
Drag and drop assign activity in “Task outcome is YES” branch and name is Assign_Input_OrderABCS. Assign payload from BPEL’s input variable to OrderABCS.ReadOrder’s input variable.
orafmwschool_hwflow68 orafmwschool_hwflow69
Similarly create Assign_Output_OrderABCS activity and assign response from OrderABCS to BPEL’s output variable.
orafmwschool_hwflow70 orafmwschool_hwflow71
This completes the OrderApproval BPEL process. Lets go back to composite.xml. Link OrderRouter with OrderApprovalProcess. Delete link between OrderApprovalProcess and the default client created by JDeveloper.
orafmwschool_hwflow41
Link OrderApprovalProcess with OrderABCS as shown below.
orafmwschool_hwflow43
We need to create routing rules to send all non-EXPRESS orders to Workflow and send EXPRESS orders to Order Management system. Double click OrderRouter mediator and go to the Routing Rules section.
orafmwschool_hwflow74
Create following routing rules for OrderABCS and OrderApprovalProcess respectively.
orafmwschool_hwflow72
orafmwschool_hwflow73
HumanWorkflowExample is now ready to be deployed.
orafmwschool_hwflow50
Lets test the composite now. Create one NORMAL and one EXPRESS order in Order.txt and place it in file polling directory.
orafmwschool_hwflow53
This creates two instances of HumanWorkflowExample. One instance, with EXPRESS order entry, will directly write information to Order Management system where as the other entry creates a workflow that awaits Depot Manager’s approval.
orafmwschool_hwflow59
Click on the process Instance ID that is in “Running” stage. Process flow for this specific instance will be shown in a pop up window. We can see the process is waiting for Human Worflow stage.
orafmwschool_hwflow61
Click on the “OrderApprovalTask”. In the above screenshot, its the link on the left side of “Human Workflow Component”. From the next screen, click on “Go To Woklist Application” and login to workflow application. In my case, user name is “weblogic”. We can see an order entry pending for Approval. Click on “Actions” and then “Yes”.orafmwschool_hwflow62orafmwschool_hwflow63
Come back to HumanWorfkflowExample in Enterprice Manager and check that process is now complete.
orafmwschool_hwflow65
Click on completed process instance, in this case 150010, to see process flow. We can see that OrderRouter invoked OrderApprovalProcess when order type is NORMAL. Once approved, OrdreManagementService is invoked through OrderABCS.
orafmwschool_hwflow76
We can also see BPEL process flow by clicking on OrderApprovalProcess. Explore Audit Trail and Flow tabs from the next screen.orafmwschool_hwflow77orafmwschool_hwflow78
Hope this lessons helped you appreciate Human Worflow features better. I personally prefer BPEL workflow to traditional workflows because of the ease and elegance.
Please use the Human Workflow JDeveloper Template if you want to implement this project on your own. Complete JDeveloper project is also available from Downloads section.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...