Lesson 5: Resuming a Suspended Workflow Using AppFabric
Objective: To stop and restart a failed workflow.
Purpose: Understand how Windows Server AppFabric persists idle or suspended instances, and how to resume a suspended workflow.
You must deploy the HRApplicationServices application. For more information, see Lesson 2: Deploying the HRApplicationServices Workflow Service.
You must enable monitoring and persistence. For more information, see Lesson 3: Configuring the HRApplicationServices Application.
Simulating a Suspended Workflow
To see AppFabric in action, we must simulate a broken workflow. When that occurs, the persisted workflow is suspended. To simulate this we will “break” the HRApplicationServices application temporarily by renaming the \mailbox folder to \mailbox2.
To interrrupt the HRApplicationServices workflow
Navigate to the root of the computer’s hard disk.
Rename the mail folder from \mailbox to \mailbox2
In Internet Explorer, type or paste the application URL:
In the application form, set the education level to Masters.
Click the Apply button.
In Windows Explorer open the mailbox2 folder. Note that no message file has been generated.
Viewing and Resuming a Suspended Workflow
Now that the workflow has been disrupted, AppFabric has persisted the suspended workflow. After fixing the application, you can resume the workflow.
To view the suspended workflow
Open or return to IIS Manager.
Under Connections, navigate to the HRApplicationServices node. Click the node to select it.
Double-click AppFabric Dashboard.
In the Persisted WF Instances section there is one suspended instance. Also note that there are no service exceptions or user defined errors listed. This is because the sample application did not throw an error that was caught by the client. But because the workflow was disrupted, AppFabric persisted the suspended workflow.
Under the Persisted WF Instances section, double-click the suspended instance SubmitApplication.xamlx. The persisted instance appears in the list with the status of Suspended
Right-click the suspended instance and click View Tracked Events. (Other choices include Resume, Cancel, Terminate and Delete.)
In the list of tracked events, click the event that is has an Error icon. The Details section below the list now contains the details of the selected error event.
Click the Errors tab.
Note the exception text. It includes the following:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\mailbox
In this scenario, that information is enough to fix the application. AppFabric has captured the exception text for analysis.
Open Windows Explorer and rename the folder from \mailbox2 to \mailbox.
Return to the AppFabric dashboard.
Right-click the dashboard and click Appfabric Dashboard.
Under the Persisted WF Instances section double-click the suspended instance SubmitApplication.xamlx.
Right-click the suspended instance and click Resume.
After a few seconds, right-click the instance again and click Refresh.
In Windows Explorer open the mailbox folder. Note that there is now a message file in the folder.
Double-click the item to open it and click Review the application. (If you do not have a mail-reader program, view the message with Notepad.exe and copy and paste the URL in the message to the application into your browser to see the HTML message. The URL resembles the following:
http://localhost/HRApplicationServices/HireApproval.aspx?AppID=23Note that the
AppIDis set to the applicant ID.)
On the HTML page, click Hire to hire the applicant. Open the mailbox folder and note there is a final message file. Open it to see the good news.
Return to the AppFabric dashboard.
Right-click the dashboard and click Refresh. The dashboard will be updated and the idle instance will disappear from the Active or Idle Instances column.
What Did I Just Do?
You have simulated a disruption that resulted in a suspended workflow. After fixing the error, you have resumed the workflow using the dashboard.
Lesson 1: Getting Started
Lesson 2: Deploying the HRApplicationServices Workflow Service
Lesson 3: Configuring the HRApplicationServices Application
Lesson 4: Monitoring the Health of the HRApplicationServices Application