Share via


Exercise 5: Troubleshooting

What happens when a workflow encounters an error? If the workflow is responding to a web service message it can send a SOAP fault to let the caller know there was an error. But if the workflow is doing work after it sent a response you need a way to find out what went wrong so you can take action. What would happen if your SubmitApplication workflow was unable to send the Request Human Screening email? In this exercise, you will force an error that simulates a mail failure then use AppFabric to troubleshoot and correct the problem.

Task 0 – Opening the Solution

To begin this exercise you can use the solution you finished from Exercise 4. Alternatively, you can follow the following steps to begin with Exercise 5.

  1. Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
  2. Open the starting solution for Exercise 5 located under the \Source\Ex5\Begin folder (choosing the folder that matches the language of your preference.) Use it as the starting point for this exercise.
  3. Press CTRL+SHIFT+B to build the solution.

Task 1 – Simulating an Error Condition

  1. Using Windows Explorer, rename the C:\Mailbox folder to C:\Mailbox2 and delete any mail messages in the folder. When the workflow tries to send the email it will now fail at this step.
  2. Switch back to Visual Studio 2010, right-click on the HRClient project and select Set as StartUp Project.
  3. Press CTRL+F5 to start the HRClient project without debugging.
  4. In the Contoso HR Tool set the Education to Masters, and click the Submit button. After a few moments you should see a confirmation message that the resume is being processed. From the client perspective it appears that everything is working.
  5. In IIS Manager expand the Default Web Site, and select the HRApplicationServices application in the tree. Double-click the AppFabric Dashboard icon.
  6. In the Persisted WF Instances section at the top of the Dashboard you should see 1 instance in the Suspended state. Click the 1 to go to the Persisted WF Instances page.

    Figure 55

    You should see a suspended instance

  7. Select the one suspended instance in the list, and look at the Details pane at the bottom.
  8. Click the Errors tab. You should see Failure sending mail.

    Figure 56

    Errors tab explains why the workflow was suspended

  9. At this point, you know the problem has something to do with a failure to send email. To get more information about the error right-click the suspended instance, and select the View Tracked Events action.

    Figure 57

    To get more detail, view tracked events

  10. You will see some Warning and Error events in the list. Click on these, and then the Errors tab to see more information about the error.

    Figure 58

    The WorkflowInstanceAbort record showing the cause of the failure

  11. You can see from the error that the mail system could not find the path C:\Mailbox because you renamed it earlier to C:\Mailbox2.

Task 2 – Correcting the Error and Resuming the Workflow

  1. Switch back to Windows Explorer, and rename the C:\Mailbox2 folder to C:\Mailbox.
  2. Switch to the IIS Manager, and click the back button to return to the Persisted WF Instances page.

    Figure 59

    Click the back button to return to the Persisted WF Instances page

  3. Right-click the suspended instance, and select the Resume action. This will queue the command to resume the instance from its last persist point.

    Figure 60

    Resume the suspended instance

  4. Wait a few seconds, and click the Refresh button. You should see an empty list because the workflow resumed and completed.
  5. Return to the AppFabric Dashboard and refresh it. You should now see 1 persisted WF instance in the Active or Idle state depending upon how long it takes you to view it.
  6. In Windows Explorer go to C:\Mailbox and find the latest message. Open it, and click the link to review the application.
  7. In the review web page click the Hire or No hire button. This will send a message to the SubmitApplication workflow using the HumanScreeningCompleted operation.
  8. In the C:\Mailbox folder you should see another message with the result.
  9. Switch back to IIS Manager, and refresh the AppFrabric Dashboard. You should see the Completions count incremented by 1. Click Completions: you will be able to review the statistics about the Submit Application workflow as shown.

    Figure 61

    The completed workflow

Next Step

Summary