Common Windows Server AppFabric Sample Application

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This sample application consists of a sale client application and a sale service application. It is intended to be used with the other Windows Server AppFabric samples as a common application to help demonstrate the AppFabric features shown in the samples.

The sale service application models a simple workflow for order processing that can take advantage of built-in persistence and tracking support provided by AppFabric . The service application provides a catalog of items to client applications, and then simulates processing the orders placed by each client. Here is a simplified diagram of the workflow for the service application:

Common AppFabric Hosting Services Application

Important

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

Prerequisites

This sample is oriented toward readers who have the following experience or knowledge levels:

  • Basic knowledge of Internet Information Services (IIS)

  • Basic knowledge of Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) applications

  • Basic knowledge of Windows PowerShell

  • Basic knowledge of Microsoft SQL Server

Sample Application Location and Files

The sample files are located in the <samples>\SampleApplication folder, where <samples> is the path under which you have installed the AppFabric samples. The files for this sample include the following:

Filename Description

OrderApplication.sln

Solution file for the two projects.

SaleClient

Folder containing the SaleClient project files.

App.config, OrderManager.cs, Program.cs, SaleClient.csproj, SaleClientForm.cs, SaleClientForm.Designer.cs, SaleClientForm.resx, AssemblyInfo.cs, Resources.Designer.cs, Resources.resx, Settings.Designer.cs, Settings.settings

SaleClient project files.

OrderApplication

Folder containing the SaleService project files.

CancelOrder.cs, CatalogInitializer.cs, CatalogTypes.cs, ProcessNewOrder.cs, SaleService.csproj, SaleService.xamlx, SaleServiceTracking.tp, ShippingProcessor.cs, web.config, AssemblyInfo.cs

SaleService project files.

Setting Up This Sample Application

These steps demonstrate how to deploy and build the Order Application with Visual Studio 2010 and configure the default application pool for use with the sale service:

  1. Start Visual Studio 2010 with administrative permissions and open <samples>\SampleApplication\OrderApplication\OrderApplication.sln, where <samples> is the path under which you have installed the AppFabric samples. When you receive the prompt to create the virtual directory now, click Yes.

  2. Click the Build menu, and then click Build Solution. Verify that the two projects build with no errors in the output window.

  3. Start Internet Information Services (IIS) Manager: Click Start, point to All Programs, point to Windows Server AppFabric, and then click Internet Information Services (IIS) Manager.

  4. Expand the server node in the tree view on the left, and then click Application Pools.

  5. Right-click DefaultAppPool in the Application Pools list and then click Advanced Settings.

  6. Set .NET Framework Version to v4.0 by using the drop-down selection, and then click OK.

Running This Sample

  1. Run the client application <samples>\SampleApplication\OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  2. The form application issues a request to the sale service to send the current daily sale catalog. Depending on the running state of the service this may take about ten seconds. The SaleClient form should look similar to the following:

    Sale Client Form

  3. Notice the expiration information for the returned catalog, which indicates that the catalog expires in approximately three minutes if an order is not placed. Change the Order Quantity for 24-inch monitors to 2, and then press the TAB key to update the order form. Billing Total should now be $531.98. If the catalog expires, you can click Get New Catalog to request a new sale catalog from the service.

  4. Within three minutes of receiving the sale catalog (the catalog expires in three minutes), click Place Order and make sure that the order status changes to Order Received. The StatusText variable in the workflow captures this status change. You can configure the application with a tracking profile to track this variable. The SaleClient application will poll the workflow and show that the order has been filled within one minute. After one more minute the order will be shipped. You can cancel the order by clicking Cancel Order any time before the order is shipped, but do not cancel this order.

  5. Right-click the selected value in the Order Id text box and click Copy to copy the order ID to the Clipboard.

  6. Close the SaleClient application. While no action is needed in a hosted workflow, the workflow can be persisted for scalability. In this sample, the order ID you just copied is used for correlating persisted workflow instances with client requests.

  7. Start a new instance of the client application <samples>\SampleApplication\OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  8. Right-click inside the Order Id text box, and then click Paste to paste the order ID from the Clipboard into the Order Id text box at the bottom of the form.

  9. Click Recall. This recalls your active order and presents its current status. The workflow simulates back-end processing of an order with delays. After approximately two minutes, Order Status will cycle through the following states: Order Received, Order Filled, Order Shipped. You can configure the host with the custom tracking profile to track the order's status changes for custom reporting. While this order is being processed, you will run a new instance of the sale client application to cancel an order.

  10. Move the sale client application that contains your placed order to the right of your screen.

  11. Start a new instance of the client application <samples>\SampleApplication\OrderApplication\SaleClient\bin\Debug\SaleClient.exe.

  12. Click Get Sale Catalog to receive a new catalog. Depending on the running state of the service this may take about ten seconds.

  13. When the sale catalog is populated in the form, change the Order Quantity for "Quad Core 2.8 Ghz Processor" to 20. Press the TAB key to update the order form. Billing Total should now be $6,119.80.

  14. Click Place Order before the new catalog expires and verify that the order status changes to Order Received.

  15. Immediately click Cancel Order before the order is shipped, and verify that the order status changes to Order Canceled.

Understanding This Sample

The SaleService application was built by using the WCF workflow service application template. The catalog provided by the sale service is intended to resemble a sale run in a newspaper or online site. The sale is available for only a limited time. After the form-based client application requests the sale catalog, the user has three minutes to place an order before the workflow causes the catalog to expire.

When the user places an order, an order ID is provided by the sale service. This order ID is used for correlating persisted workflow instances with client requests. The client request can reactivate the workflow through correlation to check the status of an order or cancel the order if it has not been shipped. After an order is placed with the sale service, its status moves from "Order Received" to "Order Filled" in approximately three minutes. After approximately three more minutes the status of the order changes to "Order Shipped".

You can use a sample tracking profile (SaleServiceTracking.tp) to enable tracking on the "StatusText" and "PurchaseTotal" variables in the workflow, and you can configure the service to track information related to these variables at different points in the workflow. The tracking profile provided in this sample tracks the following information:

  • Expired catalogs

  • Orders canceled

  • Orders filled

  • Orders shipped

  • Purchase total associated with shipped orders

After the tracking information is recorded in the tracking database, you can build a status report from the tracked data. This tracking information is intended to be used in other samples.

Removing This Sample

To remove the deployed SaleService Web application:

  1. Start Internet Information Services (IIS) Manager: Click Start, click All Programs, click Windows Server AppFabric, and then click Internet Information Services (IIS) Manager.

  2. Expand the server node in the tree view on the left, expand Sites, and then expand Default Web Site.

  3. Click the OrderApplication node and then press DELETE.

  4. Click Yes to confirm removing the selected application.

See Also

Concepts

Samples