Lesson 6: Monitoring the Order Service for Exceptions

Time to complete: 20 minutes

Objective: To learn how to troubleshoot a Windows Workflow Foundation (WF) service by using Windows Server AppFabric.

Purpose: In this lesson, you will create a configuration error, and then use AppFabric to troubleshoot the error.

Prerequisites

Note the following requirements before you begin this lesson:

Procedure

You will go through the following steps in this lesson:

  1. Creating a configuration error

  2. Configuring AppFabric for troubleshooting

  3. Creating a workflow instance

  4. Troubleshooting the workflow instance

  5. Resuming the workflow instance

Creating a Configuration Error

In this step, you intentionally misconfigure an endpoint address for OrderProcessingService so that the service cannot be invoked by OrderWorkflowService.

To misconfigure the OrderProcessingService WCF service endpoint

  1. Start or switch to the IIS Manager window.

  2. Expand the server node, expand Sites, and then click OrderService.

  3. Double-click Endpoints.

  4. From the endpoints list, click the endpoint of OrderProcessingService that exposes the Microsoft.Samples.Dublin.Tutorials.OrderService.OrderProcesingService.IOrderProcessing contract to select it.

  5. From the Actions pane on the right, click Configure to open the Configure Endpoint dialog box.

  6. In the Endpoint address box, type WrongAddress, and then click OK.

    f8a06071-7644-4e0d-9309-80b0e4c77e5c

  7. From the endpoints list, you should see the address for the endpoint has been updated to WrongAddress.

Configuring the Workflow Service for Troubleshooting

To make sure you get the information you need for troubleshooting, you must configure monitoring and persistence for the workflow service.

AppFabric defines five monitoring levels. The top level is called Troubleshooting. Typically you do not want to use this level because it slows down the overall server performance. However, for purposes of troubleshooting the workflow service, you want to enable it so you can get enough information to identify the problem.

You can configure the monitoring level at the Web site scope or the Web application scope. The Web application inherits the Web site configurations unless you set the properties explicitly. We recommend that you generally configure the monitoring level to the Web application scope to minimize the impact on performance.

To increase the event tracking level

  1. Start or switch to the IIS Manager window.

  2. Expand the server node, expand Sites, expand OrderService, and then click OrderWorkflowSerivce to select it.

  3. From the Actions pane, under Manage WCF and WF Services, click Configure to open the Configure WF and WCF for Application dialog box.

  4. In the left pane, click Monitoring.

  5. In the details pane, drag the Level slider to the top (or Troubleshooting).

  6. Click OK to close the dialog box.

You can configure how AppFabric reacts to unhandled exceptions. The default setting is Abandon. Here is the list of the actions:

Action Note

Abandon

The workflow engine aborts the workflow instance and unloads it from memory. The workflow instance status remains the same. Workflow Management Service (WMS) will retry the instance based on the settings in the WorkflowManagementService.exe.config file.

AbandonAndSuspend

The workflow engine aborts the workflow instance and unloads it from memory. The workflow instance status is changed to “Suspended”. Users can resume the workflow instance manually.

Terminate

The workflow engine aborts the workflow instance and unloads it from memory. The workflow instance status is changed to “Completed (Terminated)”.

Cancel

The workflow engine invokes any cancellation handlers that are defined in the workflow.

The tutorial is intentionally designed for you to manually resume the workflow instance after the problem is resolved. Therefore you will configure it to use the AbandonAndSuspend action.

To configure the action on unhandled exception

  1. Start or switch to the IIS Manager window.

  2. Expand the server node, expand Sites, and then click OrderService.

  3. Double-click Services.

  4. Right-click Microsoft.Samples.Dublin.Tutorials.OrderService.OrderWorkflowService.OrderWorkflow, and then click Configure to open the Configure Service dialog box.

  5. In the left pane, click Workflow Host Management.

  6. In the Action on unhandled exception box, select Abandon and suspend, and then click OK.

Creating a New Workflow Instance

In this step, you create a new workflow instance. The workflow instance will be caught in an unhandled exception because the OrderProcessingService endpoint has an incorrect address.

To create a new workflow instance

  1. Open Windows Explorer and browse to the c:\DublinTutorial\Client folder.

  2. Run OrderClient.exe.

  3. Click Submit.

  4. Switch to the Windows Explorer window, and browse to C:\DublinTutorial\Inbox.

  5. You should see only one e-mail file dropped to the folder.

  6. Close Windows Explorer.

Troubleshooting the Workflow Instance

In this step, you will troubleshoot the failed workflow instance.

To troubleshoot the workflow instance

  1. Start or switch to the IIS Manager window.

  2. Expand the server node, expand Sites, and then click OrderService.

  3. Double-click Dashboard. In the WF Instance History section, you should see that the Failures count is 1.

  4. In the WF Instance History section, click the Failures link. You should see one workflow instance listed, and the status should be Aborted.

  5. Right-click the workflow instance, and then click View Tracked Events. You should see that the third event from the top is an error.

  6. Click the error event to select it.

  7. In the Details pane, click the Errors (1) tab. You should see an exception similar to the following:

    System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://localhost:90/OrderProcessingService/OrderProcessing.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
    

    It clearly indicates There was no endpoint listening at https://localhost:90/OrderProcessingService/OrderProcessing.svc that could accept the message.

    3c3176b2-0816-4f7e-b3e6-bd458f2c92b4

  8. Follow the instructions in the Creating a Configuration Error section to correct the configuration by removing WrongAddress from the Endpoint address box.

Resuming the Workflow Instance

In the last step, you identified the problem and fixed the endpoint configuration error. You can resume the workflow instance if you set the action on the unhandled exception to AbandonAndSuspend as you did earlier in this lesson.

To resume the workflow instance

  1. Start or switch to the IIS Manager window.

  2. Expand the server node, expand Sites, and then click OrderService.

  3. Double-click Services.

  4. Right-click Microsoft.Samples.Dublin.Tutorials.OrderService.OrderWorkflowService.OrderWorkflow, and then click View Persisted WF Instances. The workflow instance should be listed with the status of Suspended.

  5. Right-click the workflow instance, and then click Resume.

  6. Open Windows Explorer, and verify the additional two e-mail files in the C:\DublinTutorial\Inbox folder. It takes about two minutes to receive the files.

What Did I Just Do?

In the lesson, you used AppFabric to troubleshoot a configuration error.

See Also

Concepts

Lesson 1: Getting Started
Lesson 2: Deploying the Order Service
Lesson 3: Configuring the Order Service
Lesson 4: Monitoring the Health of the Order Service
Lesson 5: Monitoring Custom Tracking Data for the Order Service