Working with Windows Server AppFabric
In previous post I mentioned Windows Server AppFabric.Windows Server AppFabric is a set of integrated technologies that make it easier to build, scale and manage Web and composite applications that run on IIS. Windows Server AppFabric targets applications built using ASP.NET, Windows Communication Foundation (WCF), and Windows Workflow Foundation (WF).
It provides out-of-the-box capabilities for you to easily build and manage composite applications, including:
· Enhanced design and development tools in Visual Studio to build rich composite applications;
· Management and monitoring of sevices and workflows via integration with IIS Manager and Windows PowerShell;
· Distributed in-memory application cache to improve application performance.
Windows Server AppFabric Beta 1 is available now for you as a developer to start building your next-generation composite applications, and for administrators to host and manage them. It integrates technologies previewed as code name "Dublin" and code name "Velocity". In this post I like to describe some background, how to install and configure Windows Server AppFabric, and finally how to setup and run an example provided by Microsoft.
The Windows Server AppFabric
With AppFabric Microsoft brought in the capabilities formerly in code-name “Dublin”. “Dublin” is an evolution of the Windows Process Activation service (WAS) and the Application Server role in Windows Server to host and manage WCF and WF services. AppFabric provides host capabilities for .NET 4.0 Windows Workflow Foundation and Windows Communication Foundation services, with extended management through the IIS manager, plus the ability to do service monitoring as “Dublin”.
Diagram below shows the parts of “Dublin” as well as the .NET Framework 4 and IIS components that are used by it.
More on “Dublin”architecture can be found at Microsoft Website here. Components depicted in diagram above are important to understand as they are a part of setting up Windows Server AppFabric.
Install and configure
To have Windows Server AppFabric installed you will need to a couple of things first. One is having an physical machine or preferably a virtual machine (CPU 1Ghz or higher, 1024 Mb, and 20 Gb) with Windows 2008 SP2 or Windows 2008 R2 Operating System on it or other support version: Windows 7, and Windows Vista Service Pack (SP) 2. On Windows Vista SP2 and Windows Server 2008 SP2 you must install the following IIS hot fixes:KB970772 and KB970773 after you added IIS Server Role to Operating System.
There are some known issues described in the installation guide that you need to be aware of, so download the guide before you start. The following outline shows how I prepared my environment before installing Windows Server AppFabric Beta 1:
• Critical Windows Updates and Hotfixes;
• IIS 7.0 Administration Pack;
• Microsoft .NET Framework 3.5 SP1;
• Microsoft .NET Framework 4 Beta 2;
• SQL Server 2008 Express Edition with Tools;
• Visual Studio 2010 Professional Beta 2;
Note if you run into a pop-window stating that if has to determine diskspace do the following:
msiexec.exe -package <MyPackage.msi> –qr
Also do not get annoyed by the fact that you have to reboot a number of times.
The above process of updates, fixes and installations took a couple of hours before you finally can start Installing and Configuring Application Server Extensions for .NET 4 (Window Server AppFabric). Using the table below, you can open the appropriate setup program (download from Windows Server AppFabric Beta 1 site):
Platform | Setup package |
Windows Vista SP2 and Windows Server 2008 SP2 x64 | AseSetup_amd64_6.0.exe |
Windows 7 and Windows Server 2008 R2 x64 | AseSetup_amd64_6.1.exe |
Windows Vista SP2 and Windows Server 2008 SP2 x86 | AseSetup_x86_6.0.exe |
Windows 7 x86 | AseSetup_x86_6.1.exe |
1. Use the right setup program for your environment and open it.
2. On the Accept License Terms page, accept the terms and then click Next.
3. On the Feature Selection page, select the application server components that you want to install to reliably host and manage WF and WCF applications, and then click Next.
Features
Control | Description |
Worker | Application server components that enable you to reliably host and manage WF/ WCF applications |
Distributed Cache Service | The distributed cache NT service and related components that enable you to prepare this host as a Distributed Cache Service, turning the server into the node of a cluster. You can create a new cluster or join this host to an existing cluster of Distributed Cache Services. |
Distributed Cache Client | The client libraries that enable you to use Distributed Cache functionality in your applications |
Distributed Cache Admin | Components that enable you to administer a Distributed Cache cluster. |
Note: If prerequisite software needs to be installed, the setup wizard will display the Platform Detection page after the Feature Selection page. If all prerequisites have already been installed, the setup wizard will proceed directly to the Monitoring Settings page.
4. On the Platform Detection page, review the information and download any necessary prerequisite software. When this is complete, click Next.
5. On the Monitoring Settings page, use the tables below to configure the Monitoring database, and then click Next.
Event Collector service configuration
Control | Description |
Event Collector service account | The Windows logon account for the Event Collector service. The Event Collector service account is a member of the Administrators group, and has administrative access to the Monitoring database. Default is NT Authority\System. For more information, see the section “System Security Roles” in the online Help. |
Browse | If you click the Browse button for the Event Collector service account, you will be able to select the user credential for system services. You can enter a custom user name and password, or select NT Authority\System. |
Root Monitoring configuration
Control | Description |
Configure root monitoring behavior | Select to change either the ADO .NET Provider or the connection string. |
ADO .NET Provider: | The provider that will give access to the Monitoring database. All valid data providers registered on the local machine.config file will be displayed in this list. |
Connection string: | String specifying the server and database used to save monitoring events. |
Edit | Enables you to enter a custom connection string by entering the server and selecting the database, or to select the default connection string. |
Note: This page will be displayed only if you selected Worker on the Feature Selection page.
6. On the Persistence Settings page, use the tables below to configure the Persistence database, and then click Next.
Workflow Management service configuration
Control | Description |
Workflow Management service account | The Windows logon account for the Workflow Management service. The Workflow Management service account is a member of the Administrators group, and has administrative access to the Persistence database. Default is NT Authority\Local Service. |
Browse | If you click the Browse button for the Workflow Management service account, you will be able to select the user credential for system services. You can enter a user name and password, or select NT Authority\Local Service. |
Root Persistence configuration
Control | Description |
Configure root persistence behavior | Select to enable editing of the Persistence database connection string, and to add the connection string and persistence behavior to the root. |
Connection string: | String specifying the name and location (server) of the Persistence database. |
Edit | Enables you to enter a custom connection string by entering the server and selecting the database, or to select the default connection string. |
7. On the Distributed Cache Settings page, use the tables below to configure the Distributed Cache.
Configuration Store
Control | Description |
New Cluster/Join Cluster | Select New Cluster if this is the first computer in the cluster. When you run Setup on subsequent computers in the cluster, select Join Cluster. |
Configuration Provider | When specifying the Configuration Provider, there are two options available: a. XML Provider – Cache configuration information is stored in an XML file on a network file share. This is the default. b. System.Data.SqlClient – Cache configuration information is stored in a SQL Server database. |
Connection String or Configuration File location | · Configuration File location - If you chose XML Provider as the configuration provider, enter or browse to the network file share that will contain the XML configuration file. Note: You must manually create a network file share that is accessible to all cache servers in the cache cluster. The user account that is running the Application Server Extensions for .NET 4 setup wizard must have “Owner” or “Co-Owner” permissions to the specified network file share and “Full Control” permissions to the folder at the file system level. The Cache service must have Read/Write access to the network file share. · Connection String - If you chose System.Data.SqlClient as the Configuration Provider, enter a connection string to point to the appropriate SQL Server instance and database. Note: You must manually create the database specified in the connection string. If the database specified by the connection string does not exist, setup will return an error. |
Cluster size | Choose one of the following three options to optimize performance based on cluster size. This setting is available only if Configuration Store is set to New Cluster. · Small [1-5 computers] · Medium [6-15 computers] · Large [> 15 computers] Note:Once this selection has been set, it cannot be changed. Note : Your cluster size is not limited by this selection. You can still add or remove computers from the cluster after optimization. However, performance will only be optimized when the cluster size is within the range specified. |
Host Configuration
These settings will be available only if you selected Distributed Cache Service on the Feature Selection page.
Control | Description |
Ports | Displays the default values for the cluster’s Cluster Port, Arbitrator Port, Service Port, and Replication Port. |
Firewall Rules | In order for the Application Server Extensions for .NET 4 Distributed Cache features to function, you must configure the Windows Firewall Rules to allow access for each of the following: a. Cache Service b. Remote Administration c. File and Printer Sharing |
I choose the System.Data.SqlClient for Configuration Provider.
8. On the Finalize Installation Selections page, verify the features and settings and then click Next to begin installation.
9. When installation is complete, click Close to close the wizard.
To create and initialize Monitoring and Persistence databases
1. Click Start, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
2. In the left pane, select the Server node. The name of this entry begins with the machine name.
3. In the Features View contained in the central pane, double click Monitoring Database Configuration.
4. In Monitoring Database Configuration, right-click the DefaultMonitoringConnectionString entry and select Initialize Database…. Accept the default values and then click OK.
5. Click the back arrow to return to the main Features View.
6. In the Features View pane, double-click Persistence Database Configuration.
7. Right-click the DefaultPersistenceConnectionString entry and select Initialize Database…. Accept the default values and then click OK.
Common Dublin Sample Application
This sample can be deployed on created environment explained in this blog. The example is found here. The sale service application models a simple workflow for order processing that can take advantage of built-in persistence and tracking support provided by “Dublin”. 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:
This sample requires “Dublin” (Windows Server AppFabric) to be installed with the default monitoring and persistence configuration which includes the default connections strings which are named DefaultMonitoringConnectionString and DefaultPersistenceConnectionString.
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. Launch Visual Studio 2010 with administrative permissions and open <samples>\SampleApplication\OrderApplication\OrderApplication.sln, where <samples> is the path under which you have installed the Dublin samples. When you receive the prompt to create the virtual directory now, click Yes.
2. Click the Build menu, then click Build Solution. Verify the two projects build with no errors in the output window.
3. Start Internet Information Services (IIS) Manager by clicking Start, click All Programs, click Application Server Extensions for .Net 4.0, click Internet Information Services (IIS) Manager.
4. Expand the server node in the tree view on the left, then click Application Pools.
5. Right-click DefaultAppPool in the Application Pools list and click Advanced Settings.
6. Set .NET Framework Version to v4.0 using the drop-down selection, then click OK.
Running This Sample
1. Run the client application from <samples>\ 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 Sale Client form should look similar to the following:
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 does expire, you can press the 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 Sale Client 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. The order can be canceled by clicking Cancel Order any time before the order has been shipped, but do not cancel this order.
5. Right-click the selected value in the Order Id text box and choose Copy to copy the order ID to the Clipboard.
6. Close the Sale Client 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 C:\OrderApplication\SaleClient\bin\Debug\SaleClient.exe.
8. Right-click inside the Order Id text box, and then select 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 should recall your active order and present its current status. The workflow simulates backend processing of an order with delays. After approximately two minutes, Order Status will cycle through the following states: Order Received, Order Filled, to Order Shipped. The host can be configured 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 C:\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.
Conclusion
Setting up and preparing an environment for Windows Server AppFabric does look pretty straight forward, but it is a long and tedious process getting there. As soon as you have your environment setup you can start experimenting with examples and tutorials provided by Microsoft. In this blog I took one of examples to try out the Windows Server AppFabric, which worked out fine. Good luck with trying Windows Server AppFabric yourself. I hope that with sharing my experience you will be enthusiastic to give it go.
Technorati:microsoft azure
Comments