Lab #17 Page 1 of 12 - ActiveVOS Fundamentals ActiveVOS Fundamentals Lab #17 Event Sub-processes
Lab #17 Page 2 of 12 - ActiveVOS Fundamentals Lab Plan In this lab, we ll use an Event Sub-process to define an Event Handler for the Retailer process. This provides a way for the process to accept out-of-band messages while the process is executing. For example, if a customer places an order that instantiates the process, they may want to check on the status of that order at some point. This status inquiry is related to the process, but is not a part of the process, so an Event Handler is an appropriate mechanism to respond to this request. We ll also use an Event Sub-process to define a Fault Handler, which will respond to errors generated during execution. Lab Prep Before starting make sure that: - you have completed labs #8-16. Lab Steps A. Open an existing Orchestration project 1. Open your ActiveVOS_8_Retailer project. a. Open the Retailer process file. B. Add an Event Handler to the process 1. Next, we will add an Event Sub-process that will function as an Event Handler for the process. This Event Handler will deal with an out of band request from the customer to check the status of their order. We will process the new request in parallel to the execution of the main process. a. From the Control Flow tray of the palette, drag and drop an Embedded Subprocess onto the canvas, known in BPEL as a Scope. You can expand the scope by selecting it and dragging it to the desired size using the drag handles that appear when you click on the scope container. We will use the new subprocess to define the lifecycle of the event handler, i.e., when it is enabled and when it is disabled. We ll move the process activities into the container and then drop the container back into the main sequence.
Lab #17 Page 3 of 12 - ActiveVOS Fundamentals b. Now we need to populate the scope with the appropriate activities. Drag and drop all process events and activities from Add Sales Tax to Total Cost java call to the Acknowledge Sales Order Notification reply event into the new container. To do this, simply select each of the activities and drag them into the scope, dropping them in exactly the same order. c. Your canvas will look like this:
Lab #17 Page 4 of 12 - ActiveVOS Fundamentals d. Drag the new container and drop it back into the main sequence, just after the Acknowledge Customer s Order activity. It will look like the process on the left. Use the drag handles to expand the container so we have room to work. When done, your process will look like the image on the right. 2. From the Catch tray of the palette, drag and drop an Message into the new scope.
Lab #17 Page 5 of 12 - ActiveVOS Fundamentals a. Select the Message and go to the Properties view. 1. Set the Implement as field to Scope On Event. 2. Set the Participant to Customer 3. Set the Operation to CheckOrderStatus. 4. To create a new local variable to hold the status request message, type CheckOrderStatusRequest in the Variable: field. 5. Set the Variable Definition to the Element called OrderInquiry. 3. Now that we have received the customer s status request, we need to reach out to the Order Management system in order to get the order s current status. We ll use that information to populate the response that will be sent back to the customer.
Lab #17 Page 6 of 12 - ActiveVOS Fundamentals a. Go to the Participant s view and select the OrderManager participant. b. Drop the GetOrderStatus operation inside the new Embedded Sub-process. c. Select the container and click the Auto Layout button on the toolbar. d. Go to the Properties view and rename the new invoke activity Get Order Status. e. Create Input XPath assignments that copy the customernumber and ponumber values from the customer s CheckOrderStatus request into the Input message of the GetOrderStatus invoke. f. For the Invoke s Output create a new variable called CheckOrderStatusResponse. This is the response variable that comes back from the Order Manager system with the status. We will also use this to populate the response that we will forward on to the customer with our Reply. 4. Now we have received the customer s request, we ve obtained the status from the Order Manager and finally we need to send that status back to the customer. Go to the Throw Event tray and drag a new Message event into the container, just after the Get Order Status invoke activity. a. Select the Message and go to the Properties view. b. Set the Implement as: to Reply.
Lab #17 Page 7 of 12 - ActiveVOS Fundamentals b. Name it Send Order Status To Customer. c. Set the Participant to Customer and the operation to CheckOrderStatus. d. On the Data tab, select Single Variable and CheckOrderStatusResponse. e. Change the text on the inbound request to Receive Status Check Request. e. Save the process. Note that there will be a correlation warning icon associated with the Event Handler s request message. This is expected because it is an asynchronous, inbound message. C. Simulate the Event Handler 1. Create Sample Data where needed and simulate. a. Associate sample data files for the OnEvent activity s input and for the Get Order Status invoke s response from the Order Manager. There are existing samples for each of these operations in the sample-data folder of the project. b. In the Debug view, once the simulation is running, you will see the Event Handler on a separate line, in suspend mode, as seen in the screenshot below.
Lab #17 Page 8 of 12 - ActiveVOS Fundamentals c. Once the handler becomes active, you can select it at any time to simulate it. Select the Event Handler in the Debug view. d. Control passes into the Event Handler itself and only the Step Over button is enabled. Click on Step Over or use F6. d. Simulate activities inside the Event Handler just as you would any other activity. When the activities in the Event Handler are complete, execution of the main process sequence will automatically exit the handler and then resume at the point in the main process at which you detoured from it to the Event Handler.
Lab #17 Page 9 of 12 - ActiveVOS Fundamentals D. Add a Fault Handler to the process 1. Next, we will add an Event Sub-process which will function as a Fault Handler to the process. This fault handler will respond to a WSDL fault that can be returned by the Order Manager when the CreateSalesOrder operation is invoked. a. From the Catch Event tray of the palette drag an Error into the same scope as the Event Handler. b. Select the Catch and change the text to Catch Sales Order Fault. c. Go to the Property view and click the ellipsis next to the Fault Name: field. d. When the dialog opens, select Scope Faults radio button and the OrderManager:SalesOrderFault fault.
Lab #17 Page 10 of 12 - ActiveVOS Fundamentals e. For the Fault Variable Definition: click the ellipsis button and select the Element radio button. When the dialog opens select the ordmgr:salesorderfault element. f. For the Fault Variable: field type in the name SalesOrderFaultData. 2. Now that we have the Catch itself defined, we have to define the actions we will execute in response to throwing of this fault. Because the CreateSalesOrder invoke faulted, we cannot continue the process. We will have to notify the Customer that something went wrong and we can use the existing Customer callback to do that. a. Copy the Send Order Confirmation to Customer invoke activity and paste it inside the new Catch. This copies both the activity and all of its definitions. b. Select the invoke and go to the Property sheet. Change the name to Send Sales Fault Notice to Customer. c. Go to the Input tab and change the 3 rd copy operation to N/A because we never received the CreateSalesOrder response to which this copy refers. d. Change the 4 th copy operation to Contact your representative. e. Drag a Terminate event from the Throw Event tray of the palette and drop it after the invoke. f. In the Implement as: field choose Exit. We are now ready to simulate. Your process will look like this:
Lab #17 Page 11 of 12 - ActiveVOS Fundamentals D. Simulate the Fault Handler 1. Create Sample Data where needed and simulate. a. Associate sample data with the Fault message returned by the CreateSalesOrder operation. You can do this in Participant s view, using the existing sample files.
Lab #17 Page 12 of 12 - ActiveVOS Fundamentals b. Once this sample is in place, you have to instruct the system to fault the invoke or it will run normally, which is the default. With the Create a Sales Order invoke selected, go to the Property sheet and click on the All tab. c. In the Simulation section set the Result to Fault. d. Set the Fault Name: to SalesOrderFault. e. Simulate normally, using all of the skills you have developed. When the simulation comes to the invoke it will execute the fault and control should pass into the Catch Sales Order Fault embedded sub-process.