This hands-on lab is intended to introduce developers to writing workflow services using .NET Framework 4. You will examine the different messaging activities of Windows Workflow, and learn how to configure them to create a distributed application. This lab is built around a specific HR business scenario where candidates submit their applications and are hired or rejected based on an evaluation process.
Overview
Windows Workflow Foundation (WF4) in .NET Framework 4 introduces a new way to create web services that combines the power of Windows Communication Foundation (WCF), and the flexibility of WF4. In this lab, you will learn how to use the WF4 messaging activities to implement an HR business workflow scenario. You will also experience the improved hosting, deployment, tracking and troubleshooting capabilities of the new Windows Server AppFabric.
Note:
Do I have to do all the exercises?
This lab is long. To do all of it will probably take close to 2 hours. The lab is designed so that each exercise can be done independently. Just open the solution found under the Begin folder for the exercise. For example, if you wanted to learn how Windows Server AppFabric makes it easier to deploy an application you would start with Exercise 5 and open the solution from the Source\Ex5 \Begin (choosing the folder that matches the language of your preference) folder.
Contoso has a business process for filling the open job requisitions in the company. The process will be divided in three tiers: a smart client application, a web site, a middle-tier workflow service, and a data layer.
- The applicant submits an application to a workflow service using a Windows Forms client app
- The workflow service screens the applicant’s education background by calling an Education service
- If the education screening passes, a human reviewer will receive an email with a link to the website to review the application
- The web site will call the workflow service to pass the result of the human review
- The applicant is notified by an email and a callback to the client application
Figure 1
Services Diagram for the lab solution
Objectives
In this Hands-On Lab, you will learn how to:
- Use Messaging activities to send data in and out of workflows
- Configure the Messaging activities for a specific scenario
- Invoke Add Service Reference to create activities that consume another service
- Utilize Activity Templates to create pre-configured request-reply patterns
- Set up Content Based Correlation to correlate messages from the same client
System Requirements
You must have the following items to complete this lab:
- Microsoft Visual Studio 2010 – Download
- Microsoft .NET Framework 4 – Download
- SQL Server 2008 Express (included with Visual Studio 2010) – Download
- Microsoft Outlook or Windows Live Mail Client – Download
- Windows Server AppFabric – Download using the Web Platform Installer – Donwload
Exercises
This Hands-On Lab comprises the following exercises:
- Submit Application Service
- Email Notification
- Applicant Screening
- Deploy the Solution
- Troubleshooting
Starting Materials
This Hands-On Lab includes the following starting materials.
- Visual Studio solutions. Depending on the exercise you will find Visual Studio solutions that you can use as starting point for the exercises.
Note:
What if I get stuck?
The source code that accompanies this hands-on lab includes an end folder where you can find a Visual Studio solution with the code that you would obtain if you complete the steps in each exercise. You can use this solution as a guide if you need additional help working through the exercises.
Remember to build the solutions before opening any file using the workflow designer.
Setup
All the requisites for this lab are verified using the Dependency Checker. To make sure that everything is correctly configured, follow these steps:
- Run the Dependency Checker if you have not done so previously. To do this, browse toSource\Setup folder of this lab and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.Note:The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).Note:This script file creates a persistence database by invoking the SQL scripts included with the .NET Framework. You can also use AppFabric to create persistence databases.
- If you are installing Windows Server AppFabric for the first time, you will be prompted to configure it. If you want to reconfigure it later just search for the Configure AppFabric menu shortcut. To configure AppFabric, perform the following steps:
- Start Configure AppFabric from the Start menu if it is not already running after installation.
- On the Configure Hosting Services page tick the Set monitoring configurationcheckbox.
- Select the monitoring provider System.Data.SqlClient.
- Tick the Set persistence configuration checkbox.
- Select the persistence provider sqlStoreProvider.Figure 2Configuring AppFabric monitoring and persistence stores for SQL Server
- Click the Configure button next to the Monitoring provider, and select the following options in the Monitoring Store Configuration Window:
- Check Register AppFabric monitoring store in root web.config.
- Check Initialize monitoring store.
- In the Database field, enter the name of the database to be created for monitoring data, or select an existing database from the list.
- Click OK to return to the AppFabric Configuration Wizard.Figure 3Register and Initialize the monitoring store
- Click the Configure button next to the Persistence provider, and select the following options in the Persistence Store Configuration Window:
- Check Register AppFabric persistence store in root web.config.
- Check Initialize persistence store.
- In the Database field, enter the name of the database to be created for persistence data, or select an existing database from the list.
- Click OK to return to the AppFabric Configuration Wizard.
Figure 4Register and Initialize the monitoring store
- Click the Next button to proceed to the next screen of the wizard.
- Uncheck Start Internet Information Services (IIS) Manager.
- Click Finish to complete the configuration.
Exercise 2: Verification
In this verification, you will run the HRClient application to verify that it sends the hire notification email.
|
Exercise 3: Applicant Screening
Due to the high volume of résumés that Contoso receives, they want to automate a portion of the résumé screening process. In this exercise, you will send a message to a Flowchart Workflow Service that screens candidates based on education, and then you will notify the HR reviewer of applications that need review by a human.
Task 0 – Opening the Solution
To begin this exercise, you can use the solution you finished from Exercise 2. Alternatively, you can follow the following steps to begin with Exercise 3.
- Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
- Open the starting solution for Exercise 3 located under the \Source\Ex3\Begin folder (choosing the folder that matches the language of your preference.) Use it as the starting point for this exercise.
- Press CTRL+SHIFT+B to build the solution.
Task 1 – Adding the Education Screening Activity
In this task, you will add an existing activity that screens résumés based on the level of education.
- Open ScreenEducation.xaml file of the HRApplicationServices.Activities project and explore it. This activity is implemented as a Flowchart that will be used to automatically screen out applicants based on the level of education. While the other activities in our HRApplicationServices.Activities library were implemented in code, this activity is implemented in XAML. You can create and share activities implemented in code or XAML using the Workflow Designer.Figure 31The ScreenEducation Flowchart
Task 2 – Calling the ScreenEducation Activity
- Open SubmitApplication.xamlx.
- Expand the Screen Applicant sequence.
- Add a new variable EducationPassed of type Boolean to the Screen Applicant scope. To do this:
- Click the Variables button
- Click on Create Variable
- Name the variable EducationPassed
- In the type select Boolean
- From the HRApplicationServices.Activities group drop a ScreenEducation activity onto the Screen Applicant sequence and set the following properties:
- Display Name: Auto Screen Education
- Education: ApplicationRequest.Resume.Education
- EducationPassed: EducationPassed
Task 3 – Conditionally Notifying a Human Reviewer
Not all applicants will pass the education screening. For those that do not, you need to update the database and notify them. For those that do pass you need to notify a human reviewer to check the application and make a decision.
- Drop an If activity from the Control Flow group below the Auto Screen Education activity and set its properties:
- Display Name: If Education Screen Passed
- Condition: EducationPassed
- If the applicant failed the education screen, you will simply update the database. Drop anUpdateHireApproved activity from the HRApplicationServices.Activities group on the Else part of the If activity and set the properties. The Hire variable defaulted to False so the applicant will not be hired in this branch.
- Display Name: Update No Hire
- ApplicantID: ApplicationResponse.ApplicationID
- HireApproved: Hire
- If the applicant passed the education screen you need to notify a human reviewer and wait for a response. Drop a Sequence activity from the Control Flow group on the Then part of the If activity and set the properties.
- Display Name: Human Screening
- You need to send an email to the HR Administrator to let them know there is an application to review. To do this, drop the RequestHumanScreening activity from theHRApplicationServices.Activities group to the Human Screening sequence and set the properties.
- Display Name: Request Human Screening
- ApplicationID: ApplicationResponse.ApplicationID
- ApplicationRequest: ApplicationRequest
- Now you need to wait for a response from the HR Administrator. They will be using a web page to send a message to your workflow with the result of the screening. Drop aTransactedReceiveScope activity from the Messaging group below the Request Human Screening activity and set the properties.
- Display Name: When Human Screening Complete
- Add a variable HumanScreening of type HumanScreeningResult to the When Human Screening Complete scope.
- Drop a Receive activity from the Messaging group in the Request area and set the following properties:
- Operation Name: HumanScreeningCompleted
- Service Contract Name: {http://contoso.com/hr/}IApplicationService
- Content: Click to display the Content Definition dialog and set the Message data toHumanScreening
- Because this message is sent to a workflow that already exists you must use correlation to provide a way for the WorkflowServiceHost to locate the correct workflow instance. To establish correlation for this Receive activity, do the following.
- CorrelatesOn: Click to display the CorrelatesOn Definition dialog
- CorrelatesWith: ApplicationIDHandle
- Key: Double-click the AppID : Int32 value
- Click OK to dismiss the dialog
Figure 32The Correlation definition for the Human Screening Receive activity - Once the message is received you need to update the database and send a reply. Since you have more than one activity in the Body drop a Sequence and set the following property:
- Display Name: Update Human Screening Result
- Now you can set the actual Hire value from the human screening result. Because Hire was initialized to False, the only way Hire is actually set to true is if the applicant passes both automated and human screening. Drag an Assign activity from the Primitives group and drop it into the Update Human Screening Result sequence and set the properties.
- Display Name: Assign Hire
- To: Hire
- Value: HumanScreening.HiringApproved
- Drop an UpdateHireApproved activity from the HRApplicationServices.Activities group below the Assign Hire activity and set the properties.
- Display Name: Update Hire Result
- ApplicantID: ApplicationResponse.ApplicationID
- HireApproved: Hire
- Now you need to send a response to the web application. To create a SendReply activity, right-click the Receive activity, and select Create SendReply. Because the Receive activity is inside the Request area and the reply cannot be placed there the SendReply activity will be placed on the clipboard.Figure 33Create a SendReply for the receiveFigure 34Worflow Designer message saying that the SendReply activity was copied to the clipboard
- Paste the SendReply below the Update Hire Result activity and set its properties.
- Display Name: Send Human Screening Reply
- Content - Message data: True
Figure 35Human Screening Completed - From the menu select Build / Build Solution (CTRL+SHIFT+B).
Task 4 – Sending Human Screening Results
The HireApproval.aspx page will need to call the SubmitApplication.xamlx workflow. Even though they are in the same website the way you call into the workflow is by sending it a message. In this task, you will modify the page to send the hire message.
- Next we need to Add a Service Reference to send a message to the receive activity of theSubmitApplication.xamlx workflow that is waiting for the human screening result. To do this right-click the HRApplicationServices project and select Add Service Reference.
- In the Add Service Reference dialog click Discover to find the service SubmitApplication.xamlx.
- Name the service reference Application, and click OK to generate the reference. After the proxy was generated by Visual Studio, make sure that the Web.config file has the following endpoint configuration.XML
- <endpoint address="http://localhost:62305/SubmitApplication.xamlx"
- binding="basicHttpBinding"
- bindingConfiguration="BasicHttpBinding_IApplicationService"
- contract="Application.IApplicationService"
- name="BasicHttpBinding_IApplicationService" />
- In the HRApplicationServices project, right-click HireApproval.aspx, and select View Code (F7).
- Add the following namespace directives.(Code Snippet – Introduction to WF Services Lab – HireApprovalNamespace CSharp)C#
- using HRApplicationServices.Contracts;
- using HRApplicationServices.Application;
(Code Snippet – Introduction to WF Services Lab – HireApprovalNamespace VB)Visual BasicImports HRApplicationServices.Contracts Imports HRApplicationServices.Application
- Locate the SendHumanScreenComplete method, and modify the code as shown.(Code Snippet – Introduction to WF Services Lab – SendHumanScreenComplete CSharp)C#
private void SendHumanScreenComplete(bool hire)
{
- ApplicationServiceClient proxy = new ApplicationServiceClient();
- try
- {
- // Create the result
- HumanScreeningResult result = new HumanScreeningResult()
- {
- AppID = Convert.ToInt32(LabelAppID.Text),
- HiringApproved = hire,
- };
- // Wrap it in a request
- HumanScreeningCompletedRequest request =
- new HumanScreeningCompletedRequest(result);
- // Call the workflow service
- proxy.HumanScreeningCompleted(result);
- proxy.Close();
- }
- catch (Exception)
- {
- proxy.Abort();
- throw;
- }
}
(Code Snippet – Introduction to WF Services Lab – SendHumanScreenComplete VB)VBPrivate Sub SendHumanScreenComplete(ByVal hire As Boolean)
Dim proxy As ApplicationServiceClient = New ApplicationServiceClient() Try Dim result As New HumanScreeningResult With { .AppID = Convert.ToInt32(LabelAppID.Text), .HiringApproved = hire } proxy.HumanScreeningCompleted(result) proxy.Close() Catch ex As Exception proxy.Abort() Throw End Try
End Sub
- Press CTRL+SHIFT+B to build the solution.Note:If you are using Visual Basic and get a compilation error stating that theApplicationServiceClient type is not defined, add the SubmitApplication.vb file located atAssets\VB\HRApplicationServices to the HRApplicationServices project.
Exercise 3: Verification
In this verification, you will create a new application and verify the screening process.- Delete any mail messages from the C:\Mailbox folder.
- Right-click the HRClient project, and select Set as StartUp Project.
- Make sure that the service is already launched in the ASP.NET Development server and press F5to Debug the solution; the HRClient application should start.
- Submit a new application where the education level is Bachelors.
- The workflow should automatically reject this application and you should see a new email message in the C:\Mailbox folder. You can view the message if you like. Delete this message when finished.
- In the Contoso HR Tool click Start Again to submit a new Candidate Information Form. This time submit a new application where the education level is Masters.
- Look in C:\Mailbox. There should be a message, only this one is sent to the HR Reviewer. Right-click and open the message.Figure 36Request for Application Review
- Click the link in the message to go to the HR Job Application Approval web pageFigure 37The HR Job Application Approval page.
- Click Hire to hire the applicant. This will send a message to the workflow.
- You should see a second mail message with the hire message.
Exercise 4: Deploy the Solution
In this exercise, you will deploy, configure and monitor the solution using Windows Server AppFabric; a set of extensions to the Windows Application Server and the Windows Process Activation Service (WAS). The goal of Windows Server AppFabric is to simplify the deployment, configuration, management, and monitoring of Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) services built on .NET Framework 4.Note:Is AppFabric installed?Task 0 – Opening the Solution
To begin this exercise you can use the solution you finished from Exercise 3. Alternatively, you can follow the following steps to begin with Exercise 4.- Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
- Open the starting solution for Exercise 4 located under the \Source\Ex4\Begin folder (choosing the folder that matches the language of your preference.) Use it as the starting point for this exercise.
- Press CTRL+SHIFT+B to build the solution.
Task 1 – Creating Configuration Transformations
Your application has several service references that were created in your development environment. When you deploy the application you need to transform the Web.config file so that it uses the correct URIs from the production environment.- To create the configuration transformations in the HRApplicationServices project right-click theWeb.config file, and select Add Config Transforms.Figure 38Right-click Web.config, and select Add Config Transforms in C#Figure 39Right-click Web.config, and select Add Config Transforms in Visual Basic
- You should now see two additional config files under the original Web.config file.Figure 40You should now have config transformsNote:In Visual Basic these files are hidden by default. You must make them visible by enabling the “Show All Files” button in the Solution Explorer.
- Open the Web.Release.config file. In this file, you will add transformation instructions for how you want the Web.config file to look after deployment. Modify it as shown.(Code Snippet – Introduction to WF Services Lab – WF4 web.Release.Config XML)XML
- <?xml version="1.0"?>
- <!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
- <configuration xmlns:xdt=
- "http://schemas.microsoft.com/XML-Document-Transform">
- <!--Modify the BaseURI key -->
- <appSettings>
- <add key="BaseURI"
- value="http://localhost/HRApplicationServices"
- xdt:Transform="SetAttributes(value)"
- xdt:Locator="Match(key)"/>
- </appSettings>
- <system.serviceModel>
- <client>
- <!--Modify the endpoint addresses for production -->
- <endpoint
- address="http://localhost/HRApplicationServices/SubmitApplication.xamlx"
- binding="basicHttpBinding"
- bindingConfiguration="BasicHttpBinding_IApplicationService"
- contract="IApplicationService"
- name="BasicHttpBinding_IApplicationService"
- xdt:Transform="SetAttributes(address)" xdt:Locator="Match(name)"/>
- </client>
- </system.serviceModel>
- <system.web>
- <compilation xdt:Transform="RemoveAttributes(debug)" />
- </system.web>
- </configuration>
- Switch the current configuration to Release to do a release build by selecting it from the toolbar.Figure 41Switch to Release build
Task 2 – Creating the Deployment Package
In this task, you will use the Web Deployment feature inside Visual Studio to create a deployment package.- In the Solution Explorer, right-click the HRApplicationServices project, select Package/Publish Settings and set the options as follows.
- Items to deploy (applies to all deployment methods) section
- Only files needed to run this applicationFigure 42Items to deploy
- Only files needed to run this application
- Web Deployment Package Settings section
- Create deployment package as a zip file
- Location where package will be created:obj\Release\Package\HRApplicationServices.zip
- IIS Web site/application name to use on the destination server: Default Web Site/HRApplicationServicesFigure 43Web Deployment Package Settings
- Press CTRL+SHIFT+S to save all files – this will save your changes.
- In the Solution Explorer right-click the HRApplicationServices project, and select Build Deployment Package. You should see Publish succeeded as the status in the bottom left corner when the action has completed.
Task 3 – Deploying the Package
- In this task, you will use the Web Deployment feature inside IIS Manager to deploy the package to the local web server.
- Open Internet Information Services (IIS) Manager using the Start menu.
- Expand the Server node, expand Sites and right-click the Default Web Site. Point to Deploy and select Import Application.Figure 44Import Application in the IIS ManagerNote:If you don't see a Deploy menu option it could mean that IIS Web Deployment Tool is not installed or may need to be reconfigured. To fix this you should do the following
- For Package path browse to the location where the package was created. By default this was in the obj\Release\Package folder for the HRApplicationServices project. SelectHRApplicationServices.zip.Figure 45Select the package
- Click Next 3 times to use the defaults on the rest of the Import Application Package wizard pages. When asked if you want to run this application in the default .NET 4 application pool clickYes.
- Click Finish when the wizard has finished.
Task 4 – Enabling the net.pipe Protocol on the Application
AppFabric installs a Workflow Management Service (WMS) that works with the workflow persistence store to provide reliability and instance control. WMS communicates with the workflow service via the net.pipe protocol. Therefore, this protocol must be enabled on the application.- In IIS Manager, right-click on the Default Web Site and select the Edit Bindings option.
- Ensure that net.pipe is added with * for its Binding information. If it is not, add it using theAdd… button.Figure 46Enable the net.pipe site binding
- Click the Close button.
- Expand the Default Web Site and right-click the HRApplicationServices application in the tree. Point to Manage Application and select Advanced Settings.
- In the Enabled Protocols section add net.pipe after http as shown in the following figure.Figure 47Enable the net.pipe protocolNote:Why enable the net.pipe protocol?
- Click OK.
Task 5 – Changing the Application Configuration
While you were developing the solution you were using the WF4Persistence database for persistence. In the IIS environment you are going to use a different persistence database. You also want to configure AppFabric to suspend workflows with unhandled exceptions.- In IIS Manager, expand the Default Web Site, right-click the HRApplicationServices application, point to Manage WCF and WF Services and select Configure.
- Click the Workflow Persistence category.
- Under SQL Server Workflow Persistence select defaultSqlPersistenceStore.Figure 48Configure persistence to use DefaultPersistenceConnectionString
- Click OK to dismiss the dialog. Click Yes when you are warned about recycling the application.
Exercise 4: Verification
The Dashboard shows the activity for the services at a particular scope in the IIS tree. For example, if you click the server node at the top of the tree and then click the AppFabric Dashboard you will see activity for all the WCF and WF services on the computer. In this verification, you will look at the Dashboard at your application level.Note:To follow this verification, it is required to follow the steps in Exercise 4. Opening the End solution will not be sufficient to follow the verification since there are some IIS configuration tweaks to perform.- In IIS Manager, expand the Default Web Site, and select the HRApplicationServices application in the tree.
- At the bottom of the IIS Manager window, click Content View to see the content of the website.
- Right-click the SubmitApplication.xamlx file, and select Browse.
- You should see a browser window, with the Submit Application Service. If there are any problems with the configuration for the website this page will not appear.
- At the bottom of the IIS Manager window click Features View.
- Double-click on the AppFabric Dashboard icon.Figure 49Open the DashboardNote:What is on the Dashboard?Figure 50The Dashboard showing no activity for the HRApplicationService application
- Switch back to Visual Studio 2010.
- Open the App.config file in the HRClient project. Unlike the Web.config which transformed when you deployed it, the app.config file must be manually edited. Change the endpoint address as shown in bold text below.(Code Snippet – Introduction to WF Services Lab – WF4 ClientConfig XML)XML
<client>
- <endpoint
- address="http://localhost/HRApplicationServices/SubmitApplication.xamlx"
- binding="basicHttpBinding"
- bindingConfiguration="BasicHttpBinding_IApplicationService"
- contract="SubmitApp.IApplicationService"
- name="BasicHttpBinding_IApplicationService" />
</client>
- Right-click the HRClient project, point to Debug and click Start new instance.
- 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.
- In IIS Manager, refresh the AppFabric Dashboard. You should see activity in each of the three sections.
- Click 1 beside Active in the Persisted WF Instances section to see a list of the active persisted instances.Figure 51The SubmitApplication Workflow instance is activeNote:The host is configured by default to put active instances into the idle state after 60 seconds. If you do not have any instances in the Active state refresh the Dashboard and look for the instance in the Idle state.
- Click on the hyperlink on the word Active or Idle in the Persisted WF Instances pane. This will open a query page with Persisted WF Instances.
- Click on the persisted instance. The Details pane at the bottom of the screen will show some information about the instance. In this example, you can see that the SubmitApplication Workflow has an active bookmark named HumanScreeningCompleted. That is the operation name of the bookmark created by the receive activity that it is currently waiting on.Note:The active bookmark is visible only for instances that were idle.Figure 52Information about the persisted SubmitApplication workflow
- In the picture above you can see that there are a number of tracked events. To see these events, right-click the instance, and select the View Tracked Events action. This action will take you to theTracked Events page populated with all the monitoring information that was collected for the instance, sorted with the newest data at the top.Figure 53Monitoring collected Information for the instance in the Tracked Events feature
- The last activity to execute was the Request Human Screening activity. Click on this row and notice in the Details pane at the bottom of the screen you will see information about this event. Its state is Closed, indicating that the Request Human Screening activity has finished executing.
- In Windows Explorer, go to C:\Mailbox and find the latest message. Open it and click the link to review the application.
- 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.
- Return to IIS Manager (still on the Tracked Events page), and click Refresh button to refresh the data in the list (it may take up to a minute before the new events appear). You will now see that the remainder of the SubmitApplication workflow activities have executed.
- Return to the Dashboard and refresh it. You should now see no active or idle instances in thePersisted WF Instances section. In the WF Instance History section you should see that theSubmitApplication workflow instance has been activated and completed.Figure 54The Dashboard showing the completed workflow
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.- Start Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010.
- 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.
- Press CTRL+SHIFT+B to build the solution.
Task 1 – Simulating an Error Condition
- 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.
- Switch back to Visual Studio 2010, right-click on the HRClient project and select Set as StartUp Project.
- Press CTRL+F5 to start the HRClient project without debugging.
- 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.
- In IIS Manager expand the Default Web Site, and select the HRApplicationServices application in the tree. Double-click the AppFabric Dashboard icon.
- 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 55You should see a suspended instance
- Select the one suspended instance in the list, and look at the Details pane at the bottom.
- Click the Errors tab. You should see Failure sending mail.Figure 56Errors tab explains why the workflow was suspended
- 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 57To get more detail, view tracked events
- 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 58The WorkflowInstanceAbort record showing the cause of the failure
- 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
- Switch back to Windows Explorer, and rename the C:\Mailbox2 folder to C:\Mailbox.
- Switch to the IIS Manager, and click the back button to return to the Persisted WF Instancespage.Figure 59Click the back button to return to the Persisted WF Instances page
- 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 60Resume the suspended instance
- Wait a few seconds, and click the Refresh button. You should see an empty list because the workflow resumed and completed.
- 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.
- In Windows Explorer go to C:\Mailbox and find the latest message. Open it, and click the link to review the application.
- 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.
- In the C:\Mailbox folder you should see another message with the result.
- 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 61The completed workflow
Summary
In this lab you have learned how to build, send and receive messages using Workflow Services. You’ve also seen how you can deploy, monitor and troubleshoot services using Windows Server AppFabric.Note:Feedback
No comments:
Post a Comment