Continuing from earlier Mediator example, lets extend our use-case to include Human Workflow.
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.
In previous Mediator Example, the process we built is shown below:
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.
Delete the link between OrderFTPABCS and OrderABCS as shown below.
Similarly, delete the link between OrderWSClientService and OrderABCS.
Connect OrderWSClientService and OrderRouter.
Connect OrderFTPABCS and OrderRouter. Then connect OrderRouter and Order ABCS.
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.
In General section, enter details as shown below.
In Data section, select OrderDetailsRequest element as shown below.
In Assignment section, double click on <Edit Participant> and enter weblogic user as shown below.
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.
Double click on ApprovalProcess to open BPEL design window. Drag and drop a “Human Task” component as shown below.
Select OrderApprovalTask in Task Definition field.
Select OrderDetailsRequest as Task Parameter.
This will create OrderApprovalTask_1 component in BPEL that looks like below:
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.
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.
Similarly create Assign_Output_OrderABCS activity and assign response from OrderABCS to BPEL’s output variable.
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.
Link OrderApprovalProcess with OrderABCS as shown below.
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.
Create following routing rules for OrderABCS and OrderApprovalProcess respectively.
HumanWorkflowExample is now ready to be deployed.
Lets test the composite now. Create one NORMAL and one EXPRESS order in Order.txt and place it in file polling directory.
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.
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.
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”.
Come back to HumanWorfkflowExample in Enterprice Manager and check that process is now complete.
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.
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 leave a comment or e-mail us at firstname.lastname@example.org if you have any questions.