<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Stephen Kaufman's WebLog</title><subtitle type="html">Look who's BizTalk'in - Notes on all things integration</subtitle><id>http://blogs.msdn.com/b/skaufman/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/skaufman/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2009-08-12T17:15:00Z</updated><entry><title>Presenting at the BizTalk Summit 2012</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/12/05/presenting-at-the-biztalk-summit-2012.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/12/05/presenting-at-the-biztalk-summit-2012.aspx</id><published>2012-12-05T19:17:23Z</published><updated>2012-12-05T19:17:23Z</updated><content type="html">&lt;p&gt;As many of you know, the BizTalk Team is putting on a BizTalk Summit.&lt;/p&gt;  &lt;p&gt;The BizTalk Summit 2012 is a 2 day pre-release event to prepare for the launch of the next version of BizTalk Server. Activities at the summit will include a Keynote by Scott Guthrie, product roadmap, and technical sessions by the Engineering Team, MCS and Partners.&lt;/p&gt;  &lt;p&gt;I, along with my co-presenter Michael Muta, will be doing a presentation on Notes from the Field and will include case studies of projects and their architecture (on-premise and hybrid with Azure) along with best practices and how to get your applications ready for the cloud.&lt;/p&gt;  &lt;p&gt;This two day event is being held at the Microsoft campus December 10th and 11th.&amp;#160; If you are planning on attending check out the session and stop by and say hello.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10374950" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>Blob Storage and Shared Access Signatures</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/10/15/blob-storage-and-shared-access-signatures.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/10/15/blob-storage-and-shared-access-signatures.aspx</id><published>2012-10-16T03:02:39Z</published><updated>2012-10-16T03:02:39Z</updated><content type="html">&lt;p&gt;I am working on a project where we are uploading client files to Azure Blob Storage.&amp;#160; Blob storage is perfect for this type of application and uploading them with public access is the default behavior.&amp;#160; Therefore any anonymous client can read blob data out of your container.&amp;#160; This doesn’t work so well for this situation.&amp;#160; Luckily there is the Shared Access Signature feature.&amp;#160; &lt;/p&gt;  &lt;p&gt;The Shared Access Signature feature provides a means for you to provide permissions, policies and a time window for those permissions and policies to be valid.&amp;#160; You can also modify or revoke the permissions as necessary.&amp;#160; This is important because Azure storage works by providing a password for your storage account.&amp;#160; Anyone who has that password has access/ownership of your storage account.&amp;#160; That is why you can’t give out your shared key.&amp;#160; The only exception to this is of course if you mark your container public.&amp;#160; The Shared Access Signature features allows you to give permissions but still keep control over security.&lt;/p&gt;  &lt;p&gt;So, the Shared Access Signatures provides code that lets us separate the code that signs the request from the execution.&amp;#160; It is implemented as a query string parameter that proves that the creator of the URL is authorized to perform the operations.&amp;#160;&amp;#160; The following &lt;a href="http://msdn.microsoft.com/en-us/library/ee395415.aspx"&gt;MSDN&lt;/a&gt; article shows how to manually create the signature string.&amp;#160; This is here just so that you can see what is provided and how the string is make up.&amp;#160; In addition, there is another &lt;a href="http://msdn.microsoft.com/en-us/library/hh508996.aspx"&gt;MSDN&lt;/a&gt; article that shows how to create a shared access signature and provides the following graphic to show the part that make up the query string.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;img title="Parameter elements of a SAS URL" alt="Parameter elements of a SAS URL" src="http://i.msdn.microsoft.com/dynimg/IC588553.png" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;How can we code the blob access (upload and download) to include the Shared Access Signature?&amp;#160; &lt;/p&gt;  &lt;p&gt;The following code shows how to upload a file to blob storage using a Shared Access Signature:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; UploadBlobToAzure(&lt;span class="kwrd"&gt;string&lt;/span&gt; fileName)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (fileName == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            {
                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span class="str"&gt;&amp;quot;fileName&amp;quot;&lt;/span&gt;);
            }

            &lt;span class="kwrd"&gt;try&lt;/span&gt;
            {
                &lt;span class="rem"&gt;// create storage account&lt;/span&gt;
                &lt;span class="kwrd"&gt;string&lt;/span&gt; storageConnnectString = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;DefaultEndpointsProtocol={0}; AccountName={1}; &lt;br /&gt;                       AccountKey={2}&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;http&amp;quot;&lt;/span&gt;, ConfigurationManager.AppSettings[&lt;span class="str"&gt;&amp;quot;storageAccountName&amp;quot;&lt;/span&gt;], &lt;br /&gt;                       ConfigurationManager.AppSettings[&lt;span class="str"&gt;&amp;quot;storageAccountKey&amp;quot;&lt;/span&gt;]);
                var account = CloudStorageAccount.Parse(storageConnnectString);
               
                &lt;span class="rem"&gt;// create blob client&lt;/span&gt;
                CloudBlobClient blobStorage = account.CreateCloudBlobClient();
                
                &lt;span class="rem"&gt;//Get the container.  This is what we will attach the signature to.&lt;/span&gt;
                CloudBlobContainer container = blobStorage.GetContainerReference(&lt;span class="str"&gt;&amp;quot;&amp;lt;storagecontainername&amp;gt;&amp;quot;&lt;/span&gt;);
                container.CreateIfNotExist();

                &lt;span class="rem"&gt;//Create the shared access permissions and policy&lt;/span&gt;
                BlobContainerPermissions containerPermissions = &lt;span class="kwrd"&gt;new&lt;/span&gt; BlobContainerPermissions();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; sas = container.GetSharedAccessSignature(&lt;span class="kwrd"&gt;new&lt;/span&gt; SharedAccessPolicy()
                    {
                        SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30), Permissions = &lt;br /&gt;                            SharedAccessPermissions.Write | SharedAccessPermissions.Read
                    });
                &lt;span class="rem"&gt;//Turn off public access&lt;/span&gt;
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
                container.SetPermissions(containerPermissions);

                &lt;span class="kwrd"&gt;string&lt;/span&gt; uniqueBlobName = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;@&amp;quot;&amp;lt;storagecontainername&amp;gt;/&amp;lt;filename&amp;gt;_{0}.config&amp;quot;&lt;/span&gt;, &lt;br /&gt;                       Guid.NewGuid().ToString());

                &lt;span class="rem"&gt;//assign the shared access policy&lt;/span&gt;
                CloudBlobClient blobClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; CloudBlobClient(account.BlobEndpoint, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;br /&gt;                       StorageCredentialsSharedAccessSignature(sas));

                CloudBlob blb = blobClient.GetBlobReference(uniqueBlobName);

                &lt;span class="rem"&gt;//upload the file&lt;/span&gt;
                blb.UploadFile(fileName);

                System.Console.WriteLine(&lt;span class="str"&gt;&amp;quot;File successfully uploaded to &amp;quot;&lt;/span&gt; + blb.Uri);
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;File successfully uploaded to &amp;quot;&lt;/span&gt; + blb.Uri;
            }
            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (StorageClientException e)
            {
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Blob Storage error encountered: &amp;quot;&lt;/span&gt; + e.Message;
            }
            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception e)
            {
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Error encountered: &amp;quot;&lt;/span&gt; + e.Message;
            }
            &lt;span class="kwrd"&gt;finally&lt;/span&gt;
            {
            }
        }&lt;/pre&gt;


&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Once you upload the file then you can use the following code to access that file and download it locally:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; DownloadBlobfromAzure(&lt;span class="kwrd"&gt;string&lt;/span&gt; fileName)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (fileName == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            {
                &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span class="str"&gt;&amp;quot;fileName&amp;quot;&lt;/span&gt;);
            }

            &lt;span class="kwrd"&gt;try&lt;/span&gt;
            {
                &lt;span class="rem"&gt;// create storage account&lt;/span&gt;
                &lt;span class="kwrd"&gt;string&lt;/span&gt; storageConnnectString = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;DefaultEndpointsProtocol={0}; AccountName={1}; &lt;br /&gt;                          AccountKey={2}&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;http&amp;quot;&lt;/span&gt;, ConfigurationManager.AppSettings[&lt;span class="str"&gt;&amp;quot;storageAccountName&amp;quot;&lt;/span&gt;], &lt;br /&gt;                          ConfigurationManager.AppSettings[&lt;span class="str"&gt;&amp;quot;storageAccountKey&amp;quot;&lt;/span&gt;]);
                var account = CloudStorageAccount.Parse(storageConnnectString);;
                &lt;span class="rem"&gt;// create blob client&lt;/span&gt;
                CloudBlobClient blobStorage = account.CreateCloudBlobClient();

                CloudBlobContainer container = blobStorage.GetContainerReference(&lt;span class="str"&gt;&amp;quot;&amp;lt;storagecontainername&amp;gt;&amp;quot;&lt;/span&gt;);
                container.CreateIfNotExist();

                &lt;span class="rem"&gt;//Create the shared access permission and policy&lt;/span&gt;
                BlobContainerPermissions containerPermissions = &lt;span class="kwrd"&gt;new&lt;/span&gt; BlobContainerPermissions();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; sas = container.GetSharedAccessSignature(&lt;span class="kwrd"&gt;new&lt;/span&gt; SharedAccessPolicy()
                {
                    SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(30),
                    Permissions = SharedAccessPermissions.Write | SharedAccessPermissions.Read
                });
                &lt;span class="rem"&gt;//Turn off public access&lt;/span&gt;
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;
                container.SetPermissions(containerPermissions);

                &lt;span class="kwrd"&gt;string&lt;/span&gt; uniqueBlobName = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(fileName);

                &lt;span class="rem"&gt;//Assign the shared access policy&lt;/span&gt;
                CloudBlobClient blobClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; CloudBlobClient(account.BlobEndpoint, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;br /&gt;                      StorageCredentialsSharedAccessSignature(sas));

                &lt;span class="rem"&gt;//Get a point to the blob object&lt;/span&gt;
                CloudBlob blb = blobClient.GetBlobReference(uniqueBlobName);

                &lt;span class="kwrd"&gt;string&lt;/span&gt; fileLocation = &lt;span class="str"&gt;@&amp;quot;C:\Documents\&amp;quot;;
                int pos = fileName.IndexOf('/');
                string fname = fileName.Substring(pos + 1, fileName.Length - pos - 1 );

                //Download the blob object
                blb.DownloadToFile(fileLocation + fname);

                System.Console.WriteLine(&amp;quot;&lt;/span&gt;File successfully downloaded to &lt;span class="str"&gt;&amp;quot; + fileLocation + fname);

                return &amp;quot;&lt;/span&gt;File successfully downloaded to &lt;span class="str"&gt;&amp;quot; + fileLocation + fname;
            }
            catch (StorageClientException e)
            {
                return &amp;quot;&lt;/span&gt;Blob Storage error encountered: &lt;span class="str"&gt;&amp;quot; + e.Message;
            }
            catch (Exception e)
            {
                return &amp;quot;&lt;/span&gt;Error encountered: &amp;quot; + e.Message;
            }
            &lt;span class="kwrd"&gt;finally&lt;/span&gt;
            {
            }
        }&lt;/pre&gt;


&lt;p&gt;You may have noticed that when we created the policy we didn’t specify a SharedAccessStartTime attribute.&amp;#160; We can specify a start time that policy will be good for or we can leave it off in which case the policy will go into effect immediately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;:&amp;#160; The files names are case sensitive.&amp;#160; If you attempt to find a blob and are not using lower case for the file name you will receive a return error &lt;/p&gt;

&lt;p&gt;Outer Exception&lt;/p&gt;

&lt;p&gt;Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.&lt;/p&gt;

&lt;p&gt;Inner Exception Message&lt;/p&gt;

&lt;p&gt;{&amp;quot;The remote server returned an error: (403) Forbidden.&amp;quot;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10359873" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>Integration Patterns utilizing the Windows Azure Service Bus–Part II</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/04/16/integration-patterns-utilizing-the-windows-azure-service-bus-part-ii.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/04/16/integration-patterns-utilizing-the-windows-azure-service-bus-part-ii.aspx</id><published>2012-04-16T16:47:10Z</published><updated>2012-04-16T16:47:10Z</updated><content type="html">&lt;p&gt;In the &lt;a href="http://blogs.msdn.com/b/skaufman/archive/2012/04/16/integration-patterns-utilizing-the-windows-azure-service-bus.aspx"&gt;previous post&lt;/a&gt; I covered the Messaging Channel group of patterns. In this post, I will cover the Message Routing Group patterns.&amp;nbsp; This group contains:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Content Based Router, Message Filter, Recipient List, Splitter, Aggregator, Resequencer, Composed Message Processor, Scatter-Gather, Process Manager and Message Broker.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So, lets dive right in to each of these patterns and see how these can be implemented.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0003.ContentRouter_5F00_14869F97.png"&gt;&lt;img style="display: inline; background-image: none;" title="ContentRouter" border="0" alt="ContentRouter" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/4628.ContentRouter_5F00_thumb_5F00_5B038F9F.png" width="84" height="53"&gt;&lt;/a&gt;&amp;nbsp; &lt;font size="3"&gt;Content-Based Router&lt;/font&gt;&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;This pattern requires the the router system inspect each message and direct that message to different channels based on data elements contained in the message.&amp;nbsp; The routing should be configurable to route based on different fields, the existence or non-existence of a specific value and the routing rules should be easily maintained as there are typically frequent changes&lt;/p&gt;  &lt;p&gt;This pattern can be implement in Azure using a Service Bus Topic.&amp;nbsp; There are two parts that need to be implemented to put this pattern into use.&amp;nbsp; The first is that subscriptions need to be setup and the second is that a message needs to be created with the specific properties populated to match the subscription which follows the diagram below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/5773.ContentBasedRouter_5F00_289FBC20.jpg"&gt;&lt;img style="display: inline; background-image: none;" title="ContentBasedRouter" border="0" alt="ContentBasedRouter" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/4520.ContentBasedRouter_5F00_thumb_5F00_67913CBB.jpg" width="385" height="114"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;The following code shows to create the subscriptions as well as the submitted message.&amp;nbsp; Let’s first start by creating the subscriptions&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CBRPatternExampleWithTopic(String topicName)
 {
 String serviceNamespace = ....;
 String issuer = ....;
 String key = ....;
 
 SharedSecretCredential credential =.... 
&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; ....&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; ServiceBusNamespaceClient namespaceClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; ServiceBusNamespaceClient(serviceBusUri, credential);
 Topic topic = namespaceClient.GetTopic(topicName);&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;font color="#4bacc6"&gt; //using the AddSubscription(String, FilterExpression) method overload&lt;/font&gt; &lt;/pre&gt;

&lt;pre class="csharpcode"&gt; topic.AddSubscription(“PremiumMemberType”,&lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilter(&lt;span class="str"&gt;"MemberType = Premium"&lt;/span&gt;));&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;pre class="csharpcode"&gt; topic.AddSubscription(&lt;span class="str"&gt;"OtherMemberTypes"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilter(&lt;span class="str"&gt;"MemberType &amp;lt;&amp;gt; Premium"&lt;/span&gt;));&lt;/pre&gt;&lt;pre class="csharpcode"&gt; }&lt;/pre&gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;p&gt;Then we will create the message with the property populated that the subscriptions will key off of.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SubmitMessageToTopic()
 {
 String issuer = ....;
 String key = ....;
&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; TokenProvider tp = TokenProvider.CreateSharedSecretTokenProvider(issuer, key); 
 Uri uri = ServiceBusEnvironment.CreateServiceUri(&lt;span class="str"&gt;.., .., ..&lt;/span&gt;);

 MessagingFactory factory = MessagingFactory.Create(uri, tp);
 MessageSender myTopic = factory.CreateMessageSender(&lt;span class="str"&gt;"&amp;lt;TopicName&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;


&lt;pre class="csharpcode"&gt; BrokeredMessage message = &lt;span class="kwrd"&gt;new&lt;/span&gt; BrokeredMessage(); &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;font color="#4bacc6"&gt; //This will create a message that will be routed to the first subscription above&lt;/font&gt; &lt;/pre&gt;

&lt;pre class="csharpcode"&gt; message.Properties.Add(&lt;span class="str"&gt;"MemberType"&lt;/span&gt;, Premium); &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;font color="#4bacc6"&gt; //OR add the following property instead to have it routed to the other subscription above&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;message.Properties.Add(&lt;span class="str"&gt;"MemberType"&lt;/span&gt;, Gold);&lt;/pre&gt;


&lt;pre class="csharpcode"&gt;myTopic.Send(message);&lt;/pre&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/2068.Filter_5F00_78956A9E.png"&gt;&lt;img style="display: inline; background-image: none;" title="Filter" border="0" alt="Filter" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/1376.Filter_5F00_thumb_5F00_5F2D6764.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; &lt;font size="3"&gt;Message Filter&lt;/font&gt;&lt;/font&gt; &lt;/p&gt;

&lt;p&gt;This pattern requires that any message that doesn’t match the criteria of a subscription will be discarded.&amp;nbsp; This pattern is used to eliminate any messages that aren’t routed to a subscriber such as those setup using the Content Based Router pattern.&amp;nbsp; If the message doesn’t fall into a filter used by the subscriber then the message should be routed to a filter channel.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;When using an Azure Service Bus Topic you can utilize the RuleDescription object along with the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.filters.filteraction.aspx"&gt;FilterAction&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.filters.filterexpression.aspx"&gt;FilterExpression&lt;/a&gt; objects to setup the subscriber filters.&amp;nbsp; You can explicitly utilize the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.filters.matchnonefilterexpression.aspx"&gt;MatchNoneFilterExpression&lt;/a&gt; object to subscribe to messages that haven’t been routed to any other subscriber.&amp;nbsp; Once routed to this subscriber you can either log that the message wasn’t picked up and you can either process it or discard the message&lt;/p&gt;

&lt;p&gt;The following code shows how to add a subscriber to the Topic for a MatchNoneFilterExpression&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddFilterPatternSubscriptionToTopic(String topicName)
 {
 String serviceNamespace = ....;
 String issuer = ....;
 String key = ....;
 
 SharedSecretCredential credential =.... 
&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; ....&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; ServiceBusNamespaceClient namespaceClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; ServiceBusNamespaceClient(serviceBusUri, credential);
 Topic topic = namespaceClient.GetTopic(topicName);&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; &amp;lt;place other subscriber code here&amp;gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; RuleDescription matchNoneRule = &lt;span class="kwrd"&gt;new&lt;/span&gt; RuleDescription()
 {
     FilterAction = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilterAction(“set defer = ‘yes’;”),
     FilterExpression = &lt;span class="kwrd"&gt;new&lt;/span&gt; MatchNoneFilterExpression()
 };
 &lt;/pre&gt;

&lt;pre class="csharpcode"&gt; &lt;font color="#4bacc6"&gt;//using the AddSubscription(String, RuleDescription) method overload&lt;/font&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt; Subscription matchNoneFilterSubscription =
 topic.AddSubscription(“matchNoneFilterSubscription”, matchNoneRule);  &lt;/pre&gt;

&lt;pre class="csharpcode"&gt; }
&lt;/pre&gt;


&lt;pre class="csharpcode"&gt;&amp;nbsp;&amp;nbsp; &lt;/pre&gt;

&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/3630.DynamicRouter_5F00_2CC993E5.png"&gt;&lt;img style="display: inline; background-image: none;" title="DynamicRouter" border="0" alt="DynamicRouter" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/3146.DynamicRouter_5F00_thumb_5F00_04B6E4C6.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; Dynamic Router&lt;/font&gt; &lt;/p&gt;

&lt;p&gt; This pattern provides for the scenario in that each recipient would register and list the conditions or rules for which messages or types of messages it can handle.&amp;nbsp; The conditions or rules are stored so that when a message arrives, the rules run and the message parameters are evaluated against the rules and then the message is routed accordingly to the correct receiver.&amp;nbsp; The benefit of this is that you can achieve predictive routing, with eased maintenance and less dependency on each receiver.&lt;/p&gt;&lt;p&gt;This pattern is implemented in Azure by default in both the Topic and the Queues.&amp;nbsp; When you create a subscription and a receiver for a topic you are registering with the service and as part of that registration process you also provide rules or conditions for the types of messages or the value of properties that you want to filter for.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; what if we want to take this a step further and provide even more dynamic functionality.&amp;nbsp; What if we could implement the functionality that is available in BizTalk called &lt;u&gt;Promoted Properties&lt;/u&gt; but do it completely within the functionality of Azure.&amp;nbsp; Promoted Properties is a way of taking data contained in the body of an object or message and put that in a properties collection that can then be used to route messages.&amp;nbsp; When working with Azure, the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.brokeredmessage.aspx"&gt;BrokeredMessage&lt;/a&gt; object contains a properties collection that can be used to route however, you manually have to set these properties at design time.&amp;nbsp; Our goal is to take the values of properties in the object body itself and promote those to the BrokeredMessage properties collection so that they can be assigned and routed at run time.&lt;/p&gt;&lt;p&gt;The subscribers on the Topic still need to be created and registered but this functionality allows the data in the message to direct the flow of the message and provides further dynamic routing scenarios.&amp;nbsp; &lt;/p&gt;&lt;p&gt;I have been working with Michael Muta (MCS Consultant) and he came up with a great implementation of this pattern.&amp;nbsp; Lets look at how this can be accomplished.&amp;nbsp; &lt;/p&gt;&lt;p&gt;First, we would create a new class that will be serialized as the message body of the BrokeredMessage.&amp;nbsp; In this case we will create a class for membership.&lt;/p&gt;&lt;pre class="csharpcode"&gt;    [Serializable]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Member
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Member()
        {
            
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; NewMember { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Address { get; set; }

        [PromotedProperty(&lt;span class="str"&gt;"ReceiveEMail"&lt;/span&gt;, PropertyDirection.ReadAndWrite)]   
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ReceiveEmailAds { get; set; }

        [PromotedProperty(&lt;span class="str"&gt;"Licensed"&lt;/span&gt;, PropertyDirection.ReadOnly)]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; Licensed
        {
            get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (....); }
        }
    }&lt;/pre&gt;&lt;p&gt;As you can see we have decorated a number of the properties with custom attributes.&amp;nbsp; We decorate every property that we will want to add to the BrokeredMessage properties collection.&amp;nbsp; In addition, we can set the PropertyDirection to either ReadOnly or ReadAndWrite.&amp;nbsp; ReadOnly certainly makes sense – we just need to take a value of the property and promote that into the collection.&amp;nbsp; However, we can take this beyond just static promotion.&amp;nbsp; With the ReadAndWrite we can provide the functionality to update the property as the message is received from the Topic.&amp;nbsp; With the Subscriptions on our Topics we have the ability to perform an action in the rules.&amp;nbsp; In that action we can set the value of a property, and in this case, we can push that modification all that way back to the internal property on the object.&amp;nbsp; We can then use that for other downstream actions in our processing of the message.&amp;nbsp; This give us a lot more flexibility and functionality in our solution.&amp;nbsp; &lt;/p&gt;&lt;p&gt;After we have our object decorated we can put together the code to send the message.&amp;nbsp; We can take the same method that we used earlier to submit a message but we will do a couple of different things.&amp;nbsp; &lt;/p&gt;&lt;p&gt;As you will notice, the code to submit the message is pretty much the same – we create the factory, create the message sender, create an instance of our member object and create a BrokeredMessage.&amp;nbsp; In order to get our promoted properties code to work as an extension to the BrokereMessage we needed to utilize the Extension Methods functionality in C#.&amp;nbsp; We needed to do this because the the BrokeredMessage class is sealed.&amp;nbsp; One of the drawbacks of the Extension Methods functionality is that it doesn’t work on the objects constructor.&amp;nbsp; Therefore, we need to call the PromoteProperties method that is placed on the BrokeredMessage class.&amp;nbsp; By doing this, this method will interrogate all of decorated properties on your object and promote them.&amp;nbsp; &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SubmitMessageToTopic()
 {
 String issuer = ....;
 String key = ....;
&lt;/pre&gt;&lt;pre class="csharpcode"&gt; TokenProvider tp = TokenProvider.CreateSharedSecretTokenProvider(issuer, key); 
 Uri uri = ServiceBusEnvironment.CreateServiceUri(&lt;span class="str"&gt;.., .., ..&lt;/span&gt;);

 MessagingFactory factory = MessagingFactory.Create(uri, tp);
 MessageSender myTopic = factory.CreateMessageSender(&lt;span class="str"&gt;"&amp;lt;TopicName&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;font color="#008000"&gt;//Create our message body object &lt;/font&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt; Member memberItem = new Member();&lt;/pre&gt;



&lt;pre class="csharpcode"&gt; BrokeredMessage message = &lt;span class="kwrd"&gt;new&lt;/span&gt; BrokeredMessage(memberItem); &lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;font color="#4bacc6"&gt; &lt;/font&gt;&lt;font color="#008000"&gt;//Now that we have created the message and passed in our object we need to do one more thing&lt;/font&gt; &lt;/pre&gt;&lt;pre class="csharpcode"&gt; message.PromoteProperties(memberItem); &lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;font color="#4bacc6"&gt; &lt;/font&gt;&lt;font color="#008000"&gt;//even thought we are promoting properties, we can still add properties at design time as usual as shown below&lt;/font&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt; &lt;font color="#008000"&gt;//&lt;/font&gt;&lt;font color="#008000"&gt;message.Properties.Add(&lt;span class="str"&gt;"MemberType"&lt;/span&gt;, Gold);&lt;/font&gt;&lt;/pre&gt;



&lt;pre class="csharpcode"&gt; myTopic.Send(message);&lt;/pre&gt;&lt;pre class="csharpcode"&gt;}&lt;/pre&gt;&lt;p&gt;One other item I want to mention in the code above is that even though you promote properties decorated in your object you can still add properties to the BrokeredMessage properties collection at design time as usual.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;So, we now have our object decorated and we have the code to submit the message to the Topic.&amp;nbsp; Lets look at the extension method that promotes the properties.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; PromoteProperties(&lt;span class="kwrd"&gt;this&lt;/span&gt; BrokeredMessage msg, &lt;span class="kwrd"&gt;object&lt;/span&gt; serializableObject)
        {
            PropertyInfo[] properties = serializableObject.GetType().GetProperties();

            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (PropertyInfo prop &lt;span class="kwrd"&gt;in&lt;/span&gt; properties)
            {
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (PromotedProperty promotedProp &lt;span class="kwrd"&gt;in&lt;/span&gt; prop.GetCustomAttributes(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(PromotedProperty), &lt;span class="kwrd"&gt;true&lt;/span&gt;))
                {
                    &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt; = prop.GetValue(serializableObject, &lt;span class="kwrd"&gt;null&lt;/span&gt;);
                    msg.Properties.Add(promotedProp.Name, &lt;span class="kwrd"&gt;value&lt;/span&gt;);
                }
            }
        }&lt;/pre&gt;This method loops through the properties in the object, find the promoted properties and adds the value of the property with the name provided in the attribute to the BrokeredMessage’s property collection.&amp;nbsp; There are other other methods in the extension class for things such as setting the properties value for our ReadAndWrite property direction but this gives an overview on how we can add this functionality and provide not only a great implementation of this pattern but also extend the functionality of the Azure Topics and routing functionality.

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/5277.RecipientList_5F00_0A91885F.png"&gt;&lt;img style="display: inline; background-image: none;" title="RecipientList" border="0" alt="RecipientList" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/8308.RecipientList_5F00_thumb_5F00_498308FA.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; Recipient List&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;This pattern is related to the Content Based Router pattern in that the CBR pattern routes messages based on the message content.&amp;nbsp; The Recipient List pattern provides a means for the message to contain a list of one or more recipients to receive the message.&amp;nbsp; This differs from CBR in that we may want to submit a message to multiple order fulfillment suppliers in order to receive back prices thus allowing for the comparison of responses and the selection of the cheapest supplier as shown in the diagram below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/8311.RecipientList_5F00_0C7ED768.jpg"&gt;&lt;img style="display: inline; background-image: none;" title="RecipientList" border="0" alt="RecipientList" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0474.RecipientList_5F00_thumb_5F00_47660A31.jpg" width="367" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;This pattern can be implemented in the Azure Service Bus Topic very similarly to that of the Content Based Router example.&amp;nbsp;&amp;nbsp; The difference will be that we will create the subscriptions using the SQLFilter but will utilize the LIKE keyword.&amp;nbsp; This way the sender can populate the property with a comma separated list and the subscriptions will pick it up and route to N number of receivers.&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;/font&gt;

&lt;p&gt;&lt;font size="2"&gt;So, if we created three subscriptions&lt;/font&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;topic.AddSubscription(&lt;span class="str"&gt;"OtherMemberTypes"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilter(&lt;span class="str"&gt;"MemberType LIKE ‘%Premium%’"&lt;/span&gt;));&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;pre class="csharpcode"&gt;topic.AddSubscription(&lt;span class="str"&gt;"OtherMemberTypes"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilter(&lt;span class="str"&gt;"MemberType LIKE ‘%Gold%’"&lt;/span&gt;));&lt;/pre&gt;&lt;pre class="csharpcode"&gt;topic.AddSubscription(&lt;span class="str"&gt;"OtherMemberTypes"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlFilter(&lt;span class="str"&gt;"MemberType LIKE ‘%Silver%’"&lt;/span&gt;));&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&lt;font size="2"&gt;and we wanted to create a message that would be routed to Premium and Gold we would create a BrokeredMessage and set the following property:&lt;/font&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;message.Properties.Add(&lt;span class="str"&gt;"MemberType"&lt;/span&gt;, “Premium,Gold”);&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;font face="Segoe UI"&gt;This would allow us to set, at the client,  the recipients that we wanted to send the message to.&lt;/font&gt;&lt;/pre&gt;


&lt;pre class="csharpcode"&gt; &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;font color="#0000ff" size="3" face="Segoe UI"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/6758.Splitter_5F00_4A97F219.png"&gt;&lt;img style="display: inline; background-image: none;" title="Splitter" border="0" alt="Splitter" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/1440.Splitter_5F00_thumb_5F00_6A46CBE1.png" width="86" height="54"&gt;&lt;/a&gt;  Splitter&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;This pattern provides the ability to break apart a composite message into its separate message parts and process the related message parts separately.&amp;nbsp; This pattern is useful in scenarios where you might have an order that has many order items and each of the order items need to be sent to different receivers or sent to different inventory systems.&amp;nbsp;&amp;nbsp; &lt;/p&gt;

&lt;p&gt;This pattern can be implemented in Azure using the Service Bus Topic or Queue by utilizing the sessions feature.&amp;nbsp; To setup a queue or topic for sessions we need to set the RequiresSession property in the QueueDescription or SubscriptionDescription.&amp;nbsp; Then each message needs a SessionId in order to relate the individual messages.&amp;nbsp; The receiver will read a message and accept the session.&amp;nbsp; Once the session is accepted, the session is locked and other receivers won’t be able accept it.&amp;nbsp; This ensures that there are no competing receivers.&amp;nbsp; One thing to note about sessions and Azure is that session ordering is guaranteed even if the receiver crashes.&amp;nbsp; Another thing to think about is this pattern comes in handy when you need to provide support for sending messages larger than the allowed message size.&amp;nbsp; To send larger message, you can chunk the message into smaller sizes and use the session id in order to receive all the messages in the same session and then reassemble them.&lt;/p&gt;&lt;p&gt;There is a great example of this that &lt;a href="http://geekswithblogs.net/asmith/archive/2012/04/10/149275.aspx"&gt;Alan Smith&lt;/a&gt; has put together so I won’t duplicate the effort.&amp;nbsp; Take a look at his blog for an example of implementing this pattern.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/7823.Aggregator_5F00_098972B5.png"&gt;&lt;img style="display: inline; background-image: none;" title="Aggregator" border="0" alt="Aggregator" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0572.Aggregator_5F00_thumb_5F00_57259F35.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; &lt;font color="#0000ff"&gt;Aggregator&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;This pattern is related to the splitter pattern.&amp;nbsp; Whereas the splitter processes separate messages, the aggregator is used to bring all the separate messages back together.&lt;/p&gt;

&lt;p&gt;This pattern can be implemented in Azure using the Service Bus Topic and correlation.&amp;nbsp; When setting up the subscription you can use the CorrelationFilterExpression just as we did with the FilterExpressions in the code samples shown above in previous patterns.&amp;nbsp; So the submitter would set the CorrelationId property of the BrokeredMessage object to an identifier.&amp;nbsp; Then this same identifier would be used in the CorrelationFilter object that was configured when creating the subscription.&amp;nbsp; Also, you will want to know when the processing is finished for this correlation set.&amp;nbsp; You could easily create a custom property on the BrokeredMessage object (as we did previously with the MemberType property) that lists the total number of messages that are in the set or you may just decide to create a flag that states that this is the last message in the set.&amp;nbsp; Once the total count has been received or the message containing the flag is received then you can perform whatever task is required to aggregate all the messages together.&lt;/p&gt;

&lt;p&gt;You might ask, why use Correlation over Session.&amp;nbsp; The CorrelationId property provides an exact match, the CorrelationId is saved in a hash table and the CorrelationId processing is better optimized for matching performance than the SQL expression filters.&lt;/p&gt;

&lt;p&gt;There is a great example of this that &lt;a href="http://geekswithblogs.net/asmith/archive/2012/04/10/149275.aspx"&gt;Alan Smith&lt;/a&gt; has put together that is in the same article as his Splitter implementation so I won’t duplicate the effort.  Take a look at his blog for an example of implementing this pattern.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/4760.resequencer_5F00_48E72645.png"&gt;&lt;img style="display: inline; background-image: none;" title="resequencer" border="0" alt="resequencer" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/7801.resequencer_5F00_thumb_5F00_67BD9A23.png" width="94" height="54"&gt;&lt;/a&gt; Resequencer &lt;/font&gt;&lt;/p&gt;

&lt;p&gt;The Resequencer pattern provides guidance around putting messages back in order.&amp;nbsp; Individual messages may be processed by a downstream system and returned faster than other downstream systems can process their messages and thus leading to messages that are out of order.&amp;nbsp; This pattern uses a buffer to store messages so that they can be resequenced.&amp;nbsp; Typically the Resequencer does not modify the message in any way.&amp;nbsp; Once in the required order, the messages can be delivered as shown in the following diagram.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/5658.Resequencer_5F00_0289C030.jpg"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" title="Resequencer" border="0" alt="Resequencer" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/3000.Resequencer_5F00_thumb_5F00_45858E9D.jpg" width="580" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;This pattern can be implemented in Azure through a Service Bus Queue.&amp;nbsp; The queue becomes the buffer to not only store the messages that are submitted but also to store the messages that are out of order.&amp;nbsp; There are a number of steps that will be required to put this pattern in practice.&amp;nbsp; First, there is no change to the code that is used to submit the messages to the queue however you will need to populate the MessageId property of the BrokeredMessage object.&amp;nbsp; While there is nothing out of the ordinary to submit, there is a bit of work to be done by the receiver.&amp;nbsp; Next, we are going to take advantage of the Defer() method which will allow us to put a message back on to the queue that we detect is in the wrong sequence.&amp;nbsp; Then we can dequeue it later when we need that message by calling the receive message and passing in the message sequence.&amp;nbsp; This means that we need to keep a list of message sequence numbers in our code.&amp;nbsp; One thing to note is that once we defer a message and put it back on the queue the only way that we can retrieve it again is to call the receive and pass in the sequence number.&amp;nbsp; Another thing to note is that the Service Bus Sequencing may be different than the applications sequence numbering.&amp;nbsp; Therefore you may need to store both in either session state or an internal list.&lt;/p&gt;

&lt;p&gt;Lets look at the code to put this pattern into place.&amp;nbsp; &lt;/p&gt;

&lt;p&gt;First, let’s look at what is needed to send the message to the queue.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt; string&lt;/span&gt; issuer = &lt;span class="str"&gt;"...."&lt;/span&gt;;
 &lt;span class="kwrd"&gt;string&lt;/span&gt; key = &lt;span class="str"&gt;"...."&lt;/span&gt;;

 &lt;span class="rem"&gt;//create the token provider and URI that are needed to send to the MessagingFactory&lt;/span&gt;
 TokenProvider tp = TokenProvider.CreateSharedSecretTokenProvider(issuer, key); 
 Uri uri = ServiceBusEnvironment.CreateServiceUri(&lt;span class="str"&gt;"sb"&lt;/span&gt;, &lt;span class="str"&gt;"&amp;lt;ServiceNamespace&amp;gt;"&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty);

 &lt;span class="rem"&gt;//retrieve the MessageSender for the SeqQueue within the namespace&lt;/span&gt;
 MessagingFactory factory = MessagingFactory.Create(uri, tp);
 MessageSender SeqQueue = factory.CreateMessageSender(&lt;span class="str"&gt;"SeqQueue"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt; //create a message and use a string for the body.  We will put the sequence here as well as in a property.&lt;/span&gt;
 BrokeredMessage message1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; BrokeredMessage(&lt;span class="str"&gt;"MessageSequence 1”&lt;/span&gt;);

 &lt;span class="rem"&gt;//set some additional custom app-specific properties&lt;/span&gt;
 message.Properties[&lt;span class="str"&gt;"MessageNumber"&lt;/span&gt;] = &lt;span class="str"&gt;"1"&lt;/span&gt;;
 message.Properties[&lt;span class="str"&gt;"TotalMsgsInSequence"&lt;/span&gt;] = &lt;span class="str"&gt;"3"&lt;/span&gt;;   
&lt;span class="rem"&gt; //send the first message to the queue&lt;/span&gt;
 SeqQueue.Send(message1);&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;//create the next message in the sequence. This message will be out of order.&lt;/span&gt;
 BrokeredMessage message3 = &lt;span class="kwrd"&gt;new&lt;/span&gt; BrokeredMessage(&lt;span class="str"&gt;"MessageSequence 3”&lt;/span&gt;);
 message.Properties[&lt;span class="str"&gt;"MessageNumber"&lt;/span&gt;] = &lt;span class="str"&gt;"3"&lt;/span&gt;;
 message.Properties[&lt;span class="str"&gt;"TotalMsgsInSequence"&lt;/span&gt;] = &lt;span class="str"&gt;"3"&lt;/span&gt;;   
&lt;span class="rem"&gt; //send the first message to the queue&lt;/span&gt;
 SeqQueue.Send(message3);&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;//create the last message in the sequence.&lt;/span&gt;
 BrokeredMessage message2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; BrokeredMessage(&lt;span class="str"&gt;"MessageSequence 2”&lt;/span&gt;);
 message.Properties[&lt;span class="str"&gt;"MessageNumber"&lt;/span&gt;] = &lt;span class="str"&gt;"2"&lt;/span&gt;;
 message.Properties[&lt;span class="str"&gt;"TotalMsgsInSequence"&lt;/span&gt;] = &lt;span class="str"&gt;"3"&lt;/span&gt;;   
&lt;span class="rem"&gt; //send the first message to the queue&lt;/span&gt;
 SeqQueue.Send(message2);&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;/pre&gt;&lt;p&gt;Now we have three messages in our queue that are out of order.&amp;nbsp; Next, let’s look at what is needed to receive the message and process them in order.&amp;nbsp; By the way, I will be utilizing the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.queueclient.aspx"&gt;QueueClient&lt;/a&gt; object as this supports more advanced features (including sessions).&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ReadMessagesFromQueue()&lt;/pre&gt;&lt;pre class="csharpcode"&gt;{&lt;/pre&gt;&lt;pre class="csharpcode"&gt;.... &lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Read messages from queue until queue is empty: &lt;/span&gt;
 
MessageReceiver Qreceiver = queueClient.CreateReceiver(); 
List&amp;lt;MessageReceipt&amp;gt; MessageReceiptsDeferred = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;MessageReceipt&amp;gt;(); 
 
BrokeredMessage receivedMessage; 
&lt;span class="kwrd"&gt;while&lt;/span&gt; (Qreceiver.TryReceive(TimeSpan.FromSeconds(10), &lt;span class="kwrd"&gt;out&lt;/span&gt; receivedMessage)) 
{ 
     &lt;/pre&gt;&lt;pre class="csharpcode"&gt;  msgCount++;
&lt;span class="rem"&gt;  //check the received message and determine if it is in the sequence we need &lt;/span&gt;
  &lt;span class="kwrd"&gt;if&lt;/span&gt; (receivedMessage.Properties[&lt;span class="str"&gt;"MessageNumber"&lt;/span&gt;].ToString() == msgCount) 
  { 
     
     ProcessEachMessage(receivedMessage); 
  } 
&lt;span class="kwrd"&gt;  else&lt;/span&gt; 
  { 
     receivedMessage.Defer();&lt;/pre&gt;&lt;pre class="csharpcode"&gt;     &lt;span class="rem"&gt;//store the message receipt for later &lt;/span&gt;
     MessageReceiptsDeferred.Add(receivedMessage.MessageReceipt); 
  } 
} 
 
 
&lt;span class="rem"&gt;//we have now processed messages 1 and 2.  We need to go back and get message 3. &lt;/span&gt;
&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (MessageReceipt receipt &lt;span class="kwrd"&gt;in&lt;/span&gt; MessageReceiptsDeferred) 
{ 
      ProcessEachMessage(Qreceiver.Receive(receipt)); 
} 
 
 
Qreceiver.Close(); 
 
 
&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ProcessEachMessage(BrokeredMessage message) 
{ 
         &lt;span class="rem"&gt;//This is where we do the work we need to on the messages (i.e., reassemble, send off to a LOB system, etc.)&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;         //Do your work here&lt;/span&gt;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;       
         message.Complete(); 
} 
 &lt;/pre&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;This example shows you how we can put this pattern into code.&amp;nbsp; As with all code examples, there is still work that needs to be done to this code if you are going to use this as a sample.&amp;nbsp; &lt;/p&gt;&lt;p&gt;As you think about putting this pattern into practice, it could be useful for situations in which you want to process messages that have high and low priority all on one queue.&amp;nbsp; You may not know what order the messages are submitted but you can receive all the messages, process the ones marked as high priority and defer the other submitted messages and then go back and process those messages after all the high priority messages have been drained.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0535.Composed_5F00_6B7B3EF3.png"&gt;&lt;img style="display: inline; background-image: none;" title="Composed" border="0" alt="Composed" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/2117.Composed_5F00_thumb_5F00_43688FD4.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; Composed Msg. Processor&lt;/font&gt; &lt;/p&gt;

&lt;p&gt;This pattern provides guidance for message processing where there are a number of sub messages (i.e., order line items) that need to be routed to individual destinations, processed, returned and aggregated back into a single message.&amp;nbsp; This pattern is composed of a number of other patterns that include the Splitter, Content Based Router and Aggregator.&lt;/p&gt;&lt;p&gt;Because this pattern utilizes patterns already covered in this article I won’t duplicate the code as that can be found in each patterns implementation.&amp;nbsp; However, I will include a diagram that shows how these patterns can come together to create this complex pattern.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0535.ComposedMessageProcessor_5F00_5E34B5E0.jpg"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" title="ComposedMessageProcessor" border="0" alt="ComposedMessageProcessor" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/8867.ComposedMessageProcessor_5F00_thumb_5F00_159AC70F.jpg" width="746" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;Scatter-Gather&lt;/font&gt; &lt;/p&gt;

&lt;p&gt;This pattern outlines how a single message can be sent to many receivers, or a message may be split and its parts sent to many receivers so that one of many external providers may process the message.&amp;nbsp; Once the message has been processed and returned then the messages need to be aggregated and brought back into one message that will be processed.&amp;nbsp; Think of an order that could be fulfilled by a number of suppliers.&amp;nbsp; You can scatter the messages to those suppliers and gather all the responses and decide if you are going to take the first message returned and continue processing or if you analyze all the responses and take the lowest cost supplier.&amp;nbsp; Either way, once you have received all the messages you will take the message and send it on to the next step in the process.&lt;/p&gt;&lt;p&gt;To put this pattern in practice we can take implementations of other patterns.&amp;nbsp; The scatter portion can be implemented through the use of the Splitter pattern whereas the Gather portion can be implemented through the use of the Aggregator pattern.&amp;nbsp; Both of which are covered above.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font color="#0000ff" size="3"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/4744.ProcessMgr_5F00_6D1BE4FA.png"&gt;&lt;img style="display: inline; background-image: none;" title="ProcessMgr" border="0" alt="ProcessMgr" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0042.ProcessMgr_5F00_thumb_5F00_72F68893.png" width="86" height="54"&gt;&lt;/a&gt;&amp;nbsp; Process Manager&lt;/font&gt; &lt;/p&gt;&lt;p&gt;The process manager pattern outlines how you send a message through a number of processing steps that aren’t known at design time. These steps may not even be sequential.&amp;nbsp; In addition, the sequence of the processing steps may also be modified based on the results of the previously executed processing step.&lt;/p&gt;&lt;p&gt;To put this pattern into practice you can utilized Windows Workflow.&amp;nbsp; There are a number of blog articles showing how you can implement the currently released version of WF 4 in your code and deploy it to Azure.&amp;nbsp; In addition, there was a &lt;a href="http://blogs.msdn.com/b/appfabric/archive/2011/06/20/announcing-the-windows-azure-appfabric-june-ctp.aspx"&gt;CTP&lt;/a&gt; of WF in Azure that was released last summer.&amp;nbsp; Lastly, there is also the &lt;a href="http://blogs.msdn.com/b/windowsazure/archive/2011/09/01/now-available-workflow-foundation-windows-azure-activity-pack-ctp-1.aspx"&gt;Workflow Activity Pack for Windows Azure&lt;/a&gt; that allows you to run WF on-premises and interact with artifacts in Azure.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10294177" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>Integration Patterns utilizing the Windows Azure Service Bus</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/04/16/integration-patterns-utilizing-the-windows-azure-service-bus.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/04/16/integration-patterns-utilizing-the-windows-azure-service-bus.aspx</id><published>2012-04-16T16:36:56Z</published><updated>2012-04-16T16:36:56Z</updated><content type="html">&lt;p&gt;For years we have all utilized Gregor Hohpe’s Enterprise Integration Patterns book (and the &lt;a href="http://www.enterpriseintegrationpatterns.com/"&gt;web site&lt;/a&gt;).&amp;#160; Many of these patterns, if not most, are well known and there are many resources out there that talk about how these patterns can be implemented.&amp;#160; There are also a number of resources that talk about how these patterns can be implemented in BizTalk or Windows Server AppFabric.&amp;#160; &lt;/p&gt;  &lt;p&gt;However, there is very little that shows how these patterns can be implemented using the Windows Azure Service Bus.&amp;#160; This two part series will take a patterns first&amp;#160; look at how these different patterns can be implemented.&amp;#160; &lt;/p&gt;  &lt;p&gt;The patterns that will be covered in this post will focus on the Messaging Channel groupings.&amp;#160; The patterns in that fall in the Messaging Channel group contain:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Point to Point, Publish/Subscribe, Datatype Channel, Invalid Message Channel, Dead Letter Channel, Guaranteed Delivery, Channel Adapter, Messaging Bridge and Message Bus.&amp;#160;&amp;#160; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In the next post we will focus on the patterns that fall in the Message Routing group, which contain:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Content Based Router, Message Filter, Recipient List, Splitter, Aggregator, Resequencer, Composed Message Processor, Scatter-Gather, Process Manager and Message Broker.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There is also the Messaging Systems group of patterns but those are being addressed with the Azure Integration Components (that is currently in CTP).&amp;#160; As those components get closer to release I will cover those patterns as well.&lt;/p&gt;  &lt;p&gt;Lets start out by looking at each of the patterns in the Messaging Channel Group including a description of the pattern and then how it can be implemented.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Point-to-Point Channel&lt;/font&gt; requires that only one receiver gets the message.&amp;#160; If there are multiple receivers, then only one must still get the message.&amp;#160; This functionality can be done directly through WCF (the Service Bus can also be included by hosting the WCF service).&amp;#160; This pattern can also be accomplished through the use of the Service Bus Queue and controlling what services are listening. &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Publish-Subscribe Channel&lt;/font&gt; requires that the message or event sent to the channel will be delivered to each and every receiver.&amp;#160; Once the receiver obtains a copy of the message it is removed from the channel.&amp;#160; This can be implemented through the use of Service Topics.&amp;#160; &lt;/p&gt;  &lt;p&gt;A Service Bus Topic can have multiple subscriptions with each subscription being able to be individually managed.&amp;#160; The subscriber receive all messages, based on filters, that are sent once the subscriber is created.&amp;#160; If a message satisfies the filter criteria for more than one subscriber the message will be delivered to each subscriber and then onto the receiver.&amp;#160; When a message needs to be delivered to more than one subscriber, the message is not duplicated.&amp;#160; The meta data for the filter/subscriptions is stored and is tracked based on which subscriber/receiver has received the message.&amp;#160; In terms of removing it from the channel, think of the concept of ref counts.&amp;#160; One other thing to keep in mind is that if the Receiver is not online to receive the message, then it is stored until the receiver comes on-line.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/7167.pubsub_5F00_281B5546.jpg"&gt;&lt;img style="border: 0px currentcolor; display: inline; background-image: none;" title="pubsub" border="0" alt="pubsub" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0880.pubsub_5F00_thumb_5F00_78E969AE.jpg" width="363" height="121" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Datatype Channel&lt;/font&gt; requires that each channel will contain the same type of data.&amp;#160; Thereby when the receiver obtains a message from the channel it will always be the same type.&amp;#160; This can be accomplished with directly with WCF (the Service Bus can also be included by hosting the WCF service).&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;In addition, an Azure Queue can also be utilized.&amp;#160; You can create a new queue for each type of message that will flow through the queue.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Invalid Message Channel&lt;/font&gt; requires that a message that is deemed to be invalid be moved to a Invalid Message Channel where they will not be processed by the normal receiver.&lt;/p&gt;  &lt;p&gt;The Azure Queue implements the dead letter queue concept and uses the $DeadLetterQueue subqueue to store invalid messages.&amp;#160; Messages are placed in the dead letter subqueue:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;When a message expires and deadlettering for expired messages is set to true in a queue or subscription.      &lt;br /&gt;When the max delivery count for a message is exceeded on a queue or subscription.       &lt;br /&gt;When a filter evaluation exception occurs in a subscription and deadlettering is enabled on filter evaluation exceptions&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;To get to the dead letter queue you would use:&lt;/p&gt;  &lt;div&gt;   &lt;blockquote&gt;     &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; queueDeadletterPath = &lt;font color="#006080"&gt;QueueClient&lt;/font&gt;.FormatDeadLetterPath(&lt;span class="str"&gt;&amp;quot;&lt;font color="#d16349"&gt;&amp;lt;your queue name&amp;gt;&lt;/font&gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
  &lt;/blockquote&gt;
  &lt;/div&gt;

&lt;p&gt;the same behavior is available with Topics.&amp;#160; However, to get to the dead letter queue for a topic you would use:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; subscriptionDeadletterPath = &lt;font color="#006080"&gt;SubscriptionClient&lt;/font&gt;.FormatDeadLetterPath(&lt;span class="str"&gt;&amp;quot;&lt;font color="#c0504d"&gt;&amp;lt;Your Topic Name&amp;gt;&lt;/font&gt;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&lt;font color="#c0504d"&gt;&amp;lt;Subscription Name&amp;gt;&lt;/font&gt;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;/blockquote&gt;


&lt;p&gt;&lt;font color="#0000ff"&gt;Dead Letter Channel&lt;/font&gt; requires that if the system can’t deliver a message there is a mechanism to move the message to a dead letter channel.&amp;#160; This capability is handled like the Invalid Message Channel above.&amp;#160; However, check out this link from MSDN on the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.servicebus.queuepolicy.poisonmessagedrop.aspx"&gt;QueuePolicy.PoisonMessageDrop&lt;/a&gt; property.&amp;#160; It points to the prerelease documentation but it is interesting to read what is being planned.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;Guaranteed Delivery&lt;/font&gt; requires that the system persists the message so that it is not lost if there is a crash or outage.&amp;#160; In using the Service Bus Queues, you are ensured of guaranteed delivery as the queue uses SQL Azure as the backing store.&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;Channel Adapter&lt;/font&gt; requires that there is an interface so that any application can connect and be integrated with other applications.&amp;#160; The Service Bus Queues and Topics both provide a full API that can be utilized by a number of different technologies.&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;Messaging Bridge&lt;/font&gt; provides a connection between different messaging systems.&amp;#160; Essentially to transmit message that was intended for another messaging system.&amp;#160; This can be done through either the Service Bus Queues or Topics with the receiver getting the message and forwarding it to endpoints provided by the other messaging system.&amp;#160; In addition, the receiver can get the message and forward it on to on-premise messaging systems through WCF.&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;Message Bus&lt;/font&gt; provides a means for separate application to work together in a decoupled manner with the ability for the applications to be added or removed with no affect on any other applications.&amp;#160; The ability to be decoupled but still allowing the application to work together, share data and operate in a unified manner is the basis for this pattern.&amp;#160; This pattern can be easily implemented through the Azure Service Bus and WCF endpoints.&amp;#160; We will come back to this pattern again when we spend more time covering the integration components. &lt;/p&gt;

&lt;p&gt;In this post I have talked about the Service Bus Queue, but there is still some confusion between the Windows Azure Queue and the Service Bus Queue.&amp;#160; Yes, there are two Queues and they are different and have different uses and purposes.&amp;#160; Everything I have been referring to here is in reference to the Service Bus Queue.&amp;#160; You can find more information on the differences between Azure Queues and Azure Service Bus Queues in this article - &lt;a href="http://msdn.microsoft.com/library/windowsazure/hh767287(v=vs.103).aspx"&gt;Windows Azure Queues and Windows Azure Service Bus Queues - Compared and Contrasted&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lastly, in talking about Gregor Hohpe and his patterns book, there are a number of diagrams that are utilized that represent the patterns.&amp;#160; These diagrams can be downloaded and used in Visio which you can find at &lt;a title="http://www.eaipatterns.com/downloads.html" href="http://www.eaipatterns.com/downloads.html"&gt;http://www.eaipatterns.com/downloads.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10294172" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>Services Hosted in Windows Azure Service Bus</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/03/20/services-hosted-in-windows-azure-service-bus.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/03/20/services-hosted-in-windows-azure-service-bus.aspx</id><published>2012-03-20T19:50:45Z</published><updated>2012-03-20T19:50:45Z</updated><content type="html">&lt;p&gt;In my &lt;a href="http://blogs.msdn.com/b/skaufman/archive/2012/03/20/biztalk-appfabric-connect-for-services.aspx"&gt;last post&lt;/a&gt;, I talked about the BizTalk AppFabric Connect for Services functionality for BizTalk.&amp;#160; As you start to make your services accessible through the cloud you may find that you hit an error when you try to access the endpoint.&amp;#160; You might also find that your endpoint doesn’t show up in the Windows Azure Portal.&amp;#160; &lt;/p&gt;  &lt;p&gt;In my case, I saw this error, in the screen shot below, when I clicked on the URL for my service in the AppFabric portal. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/4760.clip_5F00_image002_5F00_3E574BF4.jpg"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0385.clip_5F00_image002_5F00_thumb_5F00_71B30F50.jpg" width="527" height="374" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then I saw that I had the following error in the Event Log. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/6648.clip_5F00_image0025_5F00_16D059BD.jpg"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="clip_image002[5]" border="0" alt="clip_image002[5]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-35-47-metablogapi/0044.clip_5F00_image0025_5F00_thumb_5F00_20B54B28.jpg" width="530" height="521" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I knew why the error in the Event Log was showing up.&amp;#160; I have Windows Server AppFabric installed and had configured my service to Auto-Start.&amp;#160; What I didn’t know was why I was getting the underlying error of not being able to reach watchdog.servicebus.windows.net.&amp;#160; After doing a lot of searching on-line I couldn’t find anything that could solve the problem.&lt;/p&gt;  &lt;p&gt;So, after talking to a member of the dev team who created the wizard functionality we found a fix.&amp;#160; It turns out you will get this error when the service can not communicate with Azure.&amp;#160; Since I had a proxy server in the mix, the fix was to add an entry in the config file in order for communications to flow through the proxy server.&amp;#160; When the wizard completed it created a set of artifacts in IIS including a config file.&amp;#160; Open that config file and we will add the entry below and place it just before the system.web section.&lt;/p&gt;  &lt;p&gt;...    &lt;br /&gt;&amp;lt;connectionString /&amp;gt;     &lt;br /&gt;    &lt;br /&gt;&amp;lt;system.net&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;defaultProxy useDefaultCredentials=&lt;span class="str"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;proxy proxyaddress=&lt;span class="str"&gt;&amp;quot;[your proxy address here]&amp;quot;&lt;/span&gt; /&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/defaultProxy&amp;gt;     &lt;br /&gt;&amp;lt;/system.net&amp;gt;     &lt;br /&gt;    &lt;br /&gt;&amp;lt;system.web&amp;gt;     &lt;br /&gt;...&lt;/p&gt;    &lt;p&gt;Enter your proxy address and you should see this error go away.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10285601" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>BizTalk AppFabric Connect For Services</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/03/20/biztalk-appfabric-connect-for-services.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/03/20/biztalk-appfabric-connect-for-services.aspx</id><published>2012-03-20T19:36:10Z</published><updated>2012-03-20T19:36:10Z</updated><content type="html">&lt;p&gt;Last week I spoke at the Twin Cities Connected Systems User Group Meeting.&amp;#160; The title of my presentation was Integration with Windows Azure – Connecting to the Cloud.&amp;#160; During my presentation I talked about ways to expand on-premise applications to the cloud as well as how to connect cloud applications back to on-premise resources.&amp;#160; As part of my presentation I talked about the functionality provided through the BizTalk AppFabric Connect for Services.&amp;#160; There were a number of people that hadn’t heard of it so this entry talks about what it is and how it can be used.&lt;/p&gt;  &lt;p&gt;So, as you build your composite applications, or just look to extend your current application, you may want to take advantage of the benefits offered by extending your application to Windows Azure.&amp;#160; This will let you leverage your existing on-premise artifacts, and LOB systems, in order to expose them and extend their reach to external clients in a secure manner.&lt;/p&gt;  &lt;p&gt;Microsoft released the &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f7735a19-cdb3-4f52-8e7b-c58f04c5c86a"&gt;BizTalk Server 2010 AppFabric Connect for Services&lt;/a&gt; as a new feature for BizTalk 2010 which provides functionality to expose your BizTalk artifacts (schemas and Orchestrations) as WCF Services exposed through the Windows Azure cloud.&amp;#160; This new functionality is exposed through changes to the BizTalk WCF Service Publishing Wizard.&amp;#160; When you run this wizard you will see a number of new screens in addition to the screens that you are already familiar with.&lt;/p&gt;  &lt;p&gt;To expose BizTalk services to Windows Azure, specifically Windows Azure ServiceBus, you will need to have a few prerequisite components installed.&amp;#160; &lt;/p&gt;  &lt;p&gt;First, of course, you must have BizTalk 2010 and the BizTalk development tools installed on the machine where the AppFabric Connect for Service feature will be used.&lt;/p&gt;  &lt;p&gt;Next, you must have the Windows Azure AppFabric SDK (1.0 or later) installed.&lt;/p&gt;  &lt;p&gt;Lastly, there are benefits of having Windows Server AppFabric installed.&amp;#160; While this is not a requirement, it makes configuration setting easier (such as Auto-Start).&lt;/p&gt;  &lt;p&gt;After all the pre-requisites have been installed, you will need a Windows Azure account and you will need to create a namespace for the Service Bus in the Azure Portal.&amp;#160; &lt;/p&gt;  &lt;p&gt;Once this is done then you can start the wizard and walk through each of the screens.&amp;#160; The wizard walks you through selecting the type of endpoint (service or metadata) – as it did previously.&amp;#160; The next screen will be a new screen which will fork between the functionality of the old wizard (exposing web services on-premise only) or to sprinkle in the new screens to allow you to expose the services to the cloud.&amp;#160; This screen presents a single checkbox asking if you want to add a Service Bus endpoint.&amp;#160; It also reminds you that you need to have a ServiceBus service namespace.&amp;#160; Select the checkbox (otherwise there is really no need to keep reading this post).&amp;#160; The next five screens are the same as the screen in the original wizard (select either schemas or Orchestrations, select the assembly, select the public ports, assign the target namespace (and remember to check allow anonymous access)).&amp;#160; One thing that I found very helpful is that the wizard will take all of the selected ports and merge them into a single WCF service.&amp;#160; The last two screens are specific to the configuration of the Service Bus.&amp;#160; &lt;/p&gt;  &lt;p&gt;The first is the Endpoint Configuration.&lt;/p&gt;  &lt;p&gt;&lt;img border="0" alt="" src="http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/CommunityServer-Wikis-Components-Files/00-00-00-00-05/4530.Screen_5F00_8.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;There are a number of options that will effect the output of the wizard.&amp;#160; The first is the Relay Binding option and you have three choices – BasicHTTPRelayBinding, NetTcpRelayBinding, and the WS2007HttpRelayBinding.&amp;#160; The Service Namespace is the namespace that you created in the Azure portal.&amp;#160; I am sure that this goes without saying but what you enter here must match with the name you created in the Portal.&amp;#160; &lt;/p&gt;  &lt;p&gt;The Enable Discover checkbox lets the services you are exposing be publicly discoverable through the ATOM feed page created by Azure for your Azure Service Bus account.&amp;#160; &lt;/p&gt;  &lt;p&gt;Lastly, the Enable metadata exchange on cloud tells the wizard to create the metadata endpoint in the cloud so that external clients can generate a proxy for your service.&lt;/p&gt;  &lt;p&gt;The next screen takes the authentication information that you can find on the portal site.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;img border="0" alt="" src="http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/CommunityServer-Wikis-Components-Files/00-00-00-00-05/0601.Screen_5F00_9_5F00_2.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;You will need to enter the Issuer Name and Key.&amp;#160; When you created the namespace in the Azure ServiceBus the issuer name defaults to owner.&amp;#160; Enter both the Name and Key into the text boxes.&amp;#160; The first checkbox controls whether the consumer needs to authenticate using to the relay service to consume the endpoint.&amp;#160; The second checkbox controls the same but for the metadata endpoint.&amp;#160; Since you are charged per access to your endpoints you may want to set these to prevent unauthorized access.&lt;/p&gt;  &lt;p&gt;Click Next and Finish to complete the wizard.&amp;#160; Once it is finished you will have a new Receive Port/Location and a site in IIS.&amp;#160; However, there are still a number of important steps that need to be done in order for your service to work.&lt;/p&gt;  &lt;p&gt;If you created a service based on an Orchestration then you need to bind the port to the orchestration in the BizTalk Administrator.&amp;#160; You will also need to Enable the Receive Location and Enlist the Orchestration.&lt;/p&gt;  &lt;p&gt;Next we move to IIS.&amp;#160; We need to have an Application Pool that is configured to use the .NET Framework 4.0 with the Pipeline set to Integrated.&amp;#160; Set the site to use the Application Pool by right clicking on the site that was created.&amp;#160; In the popup menu, select Manage Application and then click on Advanced Settings.&amp;#160; When the Advanced settings dialog box appears change the Application Pool to use the one you just created.&lt;/p&gt;  &lt;p&gt;Lastly, we need to start our service.&amp;#160; If you are running IIS 7.5 (Windows 7 or Windows Server 2008 R2) then you can configure Auto-Start.&amp;#160; If you are running a different OS version then you will need to start the services using the on-premise endpoint with a local client.&amp;#160; Once the service is started it will make contact with Windows Azure and register the service.&amp;#160; One thing to note is that this is the first time in the entire process that your service has communicated with Azure.&lt;/p&gt;  &lt;p&gt;If you have Windows Server AppFabric installed then configuring Auto-Start if very simple.&amp;#160; To do this, right click on your site and select Manage WCF and WF Services in the popup menu, then click the configure item in the fly out menu.&amp;#160; When the dialog box appears, select Auto-Start from the left hand side and then click the Enabled radio button.&lt;/p&gt;  &lt;p&gt;You are now ready to test your endpoint.&amp;#160; Point your browser to &lt;a href="http://&amp;lt;servicebusnamespace&amp;gt;.servicebus.windows.net"&gt;.servicebus.windows.net&amp;quot;&amp;gt;.servicebus.windows.net&amp;quot;&amp;gt;http://&amp;lt;servicebusnamespace&amp;gt;.servicebus.windows.net&lt;/a&gt;.&amp;#160; You should see the ATOM feed page and your service should be listed.&amp;#160; You can click on the service and you should see a new page with your service and MEX endpoint.&amp;#160; You can now consume this endpoint the same is if it were on-premise.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10285596" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /><category term="Azure" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/Azure/" /></entry><entry><title>Can you move a Virtual Machine from VirtualPC to Hyper-V?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2012/01/18/can-you-move-a-virtual-machine-from-virtualpc-to-hyper-v.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2012/01/18/can-you-move-a-virtual-machine-from-virtualpc-to-hyper-v.aspx</id><published>2012-01-19T00:31:43Z</published><updated>2012-01-19T00:31:43Z</updated><content type="html">&lt;p&gt;I was recently asked if I could help move a virtual machine that had been setup and running in VirtualPC and move it to run under Hyper-V.&amp;#160; &lt;/p&gt;  &lt;p&gt;The answer is yes it can be done.&amp;#160; Movement from Hyper-V to VirtualPC is not as easy (and many times not possible) but there are a number of blog posts on this topic already so I won’t cover that here.&amp;#160; One of the reasons that it is easier to move from VirtualPC to Hyper-V is that VirtualPC is only 32 bit.&amp;#160; &lt;/p&gt;  &lt;p&gt;There are a number of steps that must be occur for a successful move. &lt;/p&gt;  &lt;p&gt;First, start by uninstalling the integration components while the virtual machine is running in VirtualPC.&amp;#160; You can do this through the Add/Remove programs feature in Windows in the Virtual Machine.&amp;#160; The Hyper-V drivers and additions will not install over the VirtualPC additions and that is why you must remove them first.&lt;/p&gt;  &lt;p&gt;Next, move the vhd file to a location where it can be accessed by your Hyper-V instance.&amp;#160; Walk through the wizard to create a new virtual machine but when prompted to create a new drive or select and existing drive, pick select an existing drive and point it to your .vhd file.&lt;/p&gt;  &lt;p&gt;Finally, once you have the virtual machine configured in your Hyper-V instance then start the machine.&amp;#160; Go through the Settings Menu and install the Hyper-V additions.&amp;#160; Once you do this, the Hyper-V additions installs a new HAL as well as new drivers for network, video and sound devices.&amp;#160; The process of installing the new HAL is one of the reasons that a Hyper-V image is no longer portable back to VirtualPC.&lt;/p&gt;  &lt;p&gt;However, at this point, you might think that everything is done and you are ready to use the virtual machine.&amp;#160; Most of the time this is correct, however, there are situations that require additional steps.&amp;#160; You will know that you have additional steps if your integration components aren’t working – you can tell really quickly if your mouse doesn’t move outside of the virtual machine.&lt;/p&gt;  &lt;p&gt;You are more likely to have this occur if your virtual machine is running versions of Windows prior to Vista or if you are running Windows Server 2008 as these do not have the ability to dynamically detect the HAL at boot time.&lt;/p&gt;  &lt;p&gt;So, to fix this run MSConfig.exe – by clicking the Start menu, selecting Run and typing msconfig.&amp;#160; Once the utility launches, click on the Boot tab and click the Advanced Options Button.&amp;#160; When the BOOT Advanced Options dialog appears, click the Detect HAL checkbox and hit ok.&amp;#160; Restart the virtual machine and you should be good to go!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10258271" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Composite Applications</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2011/03/16/composite-applications.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2011/03/16/composite-applications.aspx</id><published>2011-03-16T20:49:09Z</published><updated>2011-03-16T20:49:09Z</updated><content type="html">&lt;p&gt;It has been a long time since my last blog post.&amp;#160; It certainly hasn’t been for a lack of content but it is amazing how fast time flies when you are busy.&amp;#160; I have been spending a lot of time lately working on composite applications and will be posting a number of entries around this topic.&lt;/p&gt;  &lt;p&gt;One of the first questions that people ask is what is a composite app?&amp;#160; &lt;/p&gt;  &lt;p&gt;Composite apps can take on many forms and use many differing technologies.&amp;#160; Many times people will talk about composite Apps and will only be referring to the UI tier.&amp;#160; While the concept of a UI composite can be compared to a mashup (a UI that combines publically available web based services to create a meaningful combination of information to a user) a UI composite is built to use business sources – in many scenarios these sources (assets) already exist within the organization from previous application development efforts.&amp;#160; &lt;/p&gt;  &lt;p&gt;A composite app can also refer to just the middle tier as well.&amp;#160; Many companies have spend a lot of time and money over the past many years building out SOA services.&amp;#160; A composite app can consist of orchestration services that draw on the functionality of these different services.&amp;#160; One thing to keep in mind however, is that a composite app is not make a SOA architecture.&amp;#160; Instead they they will build on top of the work that has already been done to create a SOA architecture.&amp;#160; &lt;/p&gt;  &lt;p&gt;The idea of a composite app is to build upon existing software assets to quickly bring data to consumers in new way.&amp;#160; &lt;/p&gt;  &lt;p&gt;Many of the articles and blogs on this subject talk a lot around the UI tier.&amp;#160; While that is a very important part of a composite application, I am going to spend time over the next few posts talking about composites at the middle tier.&lt;/p&gt;  &lt;p&gt;There is a very good all-up article titled &lt;a href="http://msdn.microsoft.com/en-us/library/bb220803.aspx"&gt;What Are Composite Applications&lt;/a&gt; from &lt;a href="http://blogs.msdn.com/b/atanu/"&gt;Atanu Banerjee&lt;/a&gt; where he walks through the full composite application stack.&amp;#160; In this article he outlines three steps that a solution architect must do to design a composite application.&amp;#160; Those things are to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Choose a composition stack.&lt;/strong&gt; Pick one or more containers from each tier, and a set of component types that are deployable into those containers. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Choose components.&lt;/strong&gt; Define the repository of assets that must be built from this set of component types, based on business needs. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Specify the composite application.&lt;/strong&gt; Define the ways in which those assets will be connected, to provide a particular cross-functional process. The platform should enable these connections to be loosely coupled. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Each of these things are required so that the consumer can get the most benefit.&amp;#160; Over and above this, the organization should start to benefit by realizing faster time-to-benefit turnaround as well as faster time-to-deployment.&amp;#160; These two, along with exposing existing LOB data are the three driving factors that are making the idea of composite applications so popular.&lt;/p&gt;  &lt;p&gt;In my next several posts, I will cover some of the technical choices, how to bring bridge between services that live in BizTalk and services that live in AppFabric, and some of the lessons learned. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10142306" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Twin Cities Connected Systems User Group Meeting–March 17th, 2011</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2011/03/16/twin-cities-connected-systems-user-group-meeting-march-17th-2011.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2011/03/16/twin-cities-connected-systems-user-group-meeting-march-17th-2011.aspx</id><published>2011-03-16T15:39:29Z</published><updated>2011-03-16T15:39:29Z</updated><content type="html">&lt;p&gt;If you are in Minneapolis on Thursday March 17th please join us for the Twin Cities Connected Systems User Group Meeting.&lt;/p&gt;  &lt;p&gt;The meeting takes place at 6:00 p.m. at the Microsoft offices at 8300 Norman Center Drive, Bloomington, MN 55437.&lt;/p&gt;  &lt;p&gt;Andy Morrison will be presenting on a Lap Around BizTalk 2010 and the ESB Toolkit 2.1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10142105" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="BTS User Group" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BTS+User+Group/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry><entry><title>Twin Cities Connected Systems User Group Meeting – September 16th, 2010</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/09/10/twin-cities-connected-systems-user-group-meeting-september-16th-2010.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/09/10/twin-cities-connected-systems-user-group-meeting-september-16th-2010.aspx</id><published>2010-09-10T17:16:02Z</published><updated>2010-09-10T17:16:02Z</updated><content type="html">&lt;p&gt;If you are in Minneapolis on Thursday September 16th please join us for the Twin Cities Connected Systems User Group Meeting.&lt;/p&gt;  &lt;p&gt;The meeting takes place at 6:00 p.m. at the Microsoft offices at 8300 Norman Center Drive, Bloomington, MN 55437.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/ekraus/"&gt;Eric Kraus&lt;/a&gt; and I will be speaking on: Composite Applications: Connecting and Building Workflow Applications&lt;/p&gt;  &lt;p&gt;Here is the write-up:&lt;/p&gt;  &lt;p&gt;Come learn about Composite Applications and how you can build chunks of functionality in different loosely-coupled technologies that can be used to make up a larger collective solution.&amp;#160; We will discuss how you can use SharePoint, BizTalk, Windows Server AppFabric, .NET and the LOB Adapters to build these chunks of functionality as well as the applications that consume them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10060383" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="BTS User Group" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BTS+User+Group/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Storing Application Configuration Information in SSO</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/08/31/storing-application-configuration-information-in-sso.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/08/31/storing-application-configuration-information-in-sso.aspx</id><published>2010-08-31T15:59:12Z</published><updated>2010-08-31T15:59:12Z</updated><content type="html">&lt;p&gt;For those using BizTalk, we have long had the need to store configuration information in a central location that is shared between each of the distributed BizTalk instances.&amp;#160; BizTalk itself uses SSO for all of its internal configuration information.&amp;#160; Unfortunately, we have not had a tool that allows us to take advantage of this functionality.&amp;#160; Currently, in SSO there are three different utilities to perform SSO based tasks.&amp;#160; These are the SSOConfig, SSOManage and the SSOClient utilities.&amp;#160; All of these tools focus on managing credentials.&lt;/p&gt;  &lt;p&gt;There has been a lack of tooling for the ability to create and manage configuration based applications.&amp;#160; This has now changed with the creation of the SSO Configuration MMC Snap-In.&amp;#160; This tool is an MMC based utility that allows developers to store name/value pairs in the the SSO configuration database.&amp;#160; The tool can be downloaded from the &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=94e07de1-1d33-4245-b430-9216979cd587"&gt;Microsoft downloads site&lt;/a&gt; and includes three parts.&amp;#160; &lt;/p&gt;  &lt;p&gt;These are the MMC management tool, a C# class file that provides the code necessary to access and read the configuration information and lastly, an automated MSBuild task to use for deployment of your configuration information.&lt;/p&gt;  &lt;p&gt;The MMC Snap-In provides an easy to use interface that allows you to add and manage applications, add and manage key value pairs as well as importing and exporting (in an encrypted format) configuration applications so that they can be deployed to different environments.&lt;/p&gt;  &lt;p&gt;The C# client class can be used in your application or helper assembly to read the values stored in SSO.&lt;/p&gt;  &lt;p&gt;And lastly, there is the MSBuild custom task that can be used to automate the deployment of your applications SSO configuration data.&amp;#160; All that you need to do is export the application and use the MSBuild task to automatically import your settings into your new environment.&lt;/p&gt;  &lt;p&gt;After all of this you might be asking “Why would you want to store your configuration data in SSO?”.&amp;#160;&amp;#160;&amp;#160; Well, middle tier server based applications have the need to utilize configuration data that needs to be able to be read at runtime and changed without compiling.&amp;#160; These applications also need the ability to have centrally managed and non repeated configuration information be available to all hosts in the middle tier.&amp;#160; Typically, middle tier applications implement a custom solution and the architects/developers need to create a means to replicate this information to servers when a scale out solutions are implemented.&amp;#160; Instead, this configuration can be stored directly in SSO and since SSO is already accessible to all servers in a scale out solution, we can take advantage of tools that we already use instead of creating custom solutions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10056338" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry><entry><title>Using The Windows Server AppFabric Cache with ASP.NET</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/08/30/using-the-windows-server-appfabric-cache-with-asp-net.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/08/30/using-the-windows-server-appfabric-cache-with-asp-net.aspx</id><published>2010-08-30T14:53:42Z</published><updated>2010-08-30T14:53:42Z</updated><content type="html">&lt;p&gt;It appears that I have lost some of my blog posts.&amp;nbsp; I am reposting this blog post which originally appeared back in May.&lt;/p&gt;
&lt;p&gt;Did you know that you can use the AppFabric Cache with ASP.NET?&amp;nbsp; AppFabric Cache provides an ASP.NET session state provider.&amp;nbsp; There are a number of reasons that you would want to consider using the AppFabric Cache instead of other caching technologies, including the built in ASP.NET caching. &lt;/p&gt;
&lt;p&gt;The AppFabric Cache provides a number of benefits to ASP.NET programmers.&amp;nbsp; When web applications need to maintain state, especially across a Web Farm, or needs to maintain objects across restarts AppFabric Cache provides the out of process, distributed highly available functionality you require.&amp;nbsp; In addition, because of the distributed nature of the cache you no longer need to worry about sticky routing (getting the client back to the same machine as their cached objects).&amp;nbsp; You also no longer need to add additional code and incur the overhead of storing state in a database.&amp;nbsp; By keeping activity oriented objects closer to the consuming logic you can eliminate the overhead and increase performance of your application.&lt;/p&gt;
&lt;p&gt;To utilize the AppFabric Cache ASP.NET session state provider open your applications' Web.Config file and enter the following XML fragment.&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;system.web&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sessionState&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;="Custom"&lt;/span&gt; &lt;span class="attr"&gt;customProvider&lt;/span&gt;&lt;span class="kwrd"&gt;="SessionStoreProvider"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;providers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="SessionStoreProvider"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider,&amp;nbsp; Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral,&amp;nbsp; PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;providers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sessionState&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;system.web&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;

&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10055815" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Tagging Objects in the AppFabric Cache</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/04/22/tagging-objects-in-the-appfabric-cache.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/04/22/tagging-objects-in-the-appfabric-cache.aspx</id><published>2010-04-23T03:02:00Z</published><updated>2010-04-23T03:02:00Z</updated><content type="html">&lt;P&gt;In two of my previous entries I outlined functionality and patterns used in the AppFabric Cache.&amp;nbsp; In this entry I wanted to expand and look at another area of functionality that people have come to expect when working with cache technology.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This expectation is the ability to tag content with more information than just the key.&amp;nbsp; As you start to examine this expectation you will soon find yourself asking if the tagged data can be related to each other and finally if it is possible to remove the related data.&lt;/P&gt;
&lt;P&gt;One of the nice things about the AppFabric Cache is that it is so easy to work with and can be so simple.&amp;nbsp; Then, if needed, like with this topic, you can take advantage of the addition functionality.&amp;nbsp; This is where the real benefits of AppFabric Cache come into play over the other cache alternatives.&lt;/P&gt;
&lt;P&gt;Lets take a deeper look at tagging.&amp;nbsp; Tagging is essentially assigning one or more string values to an object contained in the cache.&amp;nbsp;&amp;nbsp; The object in the cache can then be retrieved by using the tag or multiple tags.&amp;nbsp;&amp;nbsp; When you tag an object, all of the tagged objects will reside within a region.&amp;nbsp; A region is an additional container inside the cache.&amp;nbsp; Because regions are optional, if you want to use them you need to explicitly create them at runtime within your application code.&amp;nbsp; You can setup different regions for different types of related data.&amp;nbsp; When you utilize regions, you have the option to retrieve all objects in that region and therefore by default have setup a solution that now provides you access to all the dependent data.&amp;nbsp; We can take this one step further in that you can also delete all of the data within a region and not have to worry about looping through all entries to find the specific keys and their dependencies.&lt;/P&gt;
&lt;P&gt;As an example we could create a region called 'Beverages' and then we could cache all of the beverages we sell and tag each item by the type of beverage such as Soft Drink, Wine, Beer.&amp;nbsp; We could even go one step further and provide multiple tags so that we could further segment the Wine category into White or Red or Merlot, Zinfandel, Riesling, etc.&amp;nbsp; At this point the application could retrieve all of the catalog items based on the search criteria that were entered.&lt;/P&gt;
&lt;P&gt;Lets look at how we can setup the region and tags.&amp;nbsp; We will also look at the methods that are available to interact with objects using tags and lastly, how we can manage the data in the cache; adding, retrieving and deleting.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Setting Up a Region&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;The code that follows assumes that you already now how to create a cache (either through code or through the PowerShell cmdlets (as found in my previous post &lt;A href="http://blogs.msdn.com/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx" mce_href="http://blogs.msdn.com/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx"&gt;here&lt;/A&gt;)).&lt;/P&gt;
&lt;P&gt;To create a region we already need to have the cache created.&amp;nbsp; Once that is done, we can pass in the cache name, use the GetCache method and then call the CreateRegion method passing in a region name.&amp;nbsp; We can create as many regions as we need based on the manner in which you wish to segment the data.&amp;nbsp; One thing to keep in mind however is that there can be performance implications when using regions.&amp;nbsp; The code below shows how we can create the region.&lt;/P&gt;&lt;FONT size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CreateRegion(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CacheName, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; RegionName)&lt;BR&gt;{&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //This can also be kept in a config file&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (dcf != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dataCache = dcf.GetCache(CacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataCache.CreateRegion(RegionName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;Now that we have a cache with a region created lets look at the methods that are available to interact with tags&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Methods to work with tagging (from MSDN):&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH&gt;Method &lt;/TH&gt;
&lt;TH&gt;Description &lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbytag.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbytag.aspx"&gt;GetObjectsByTag&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Provides a simple way to access objects that contain tags (exact match, intersection, or union). The region name is a required parameter.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbyanytag.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbyanytag.aspx"&gt;GetObjectsByAnyTag&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Returns a list of objects that have tags matching any of the tags provided in the parameter of this method.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbyalltags.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsbyalltags.aspx"&gt;GetObjectsByAllTags&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Returns a list of objects that have tags matching all of the tags provided in the parameter of this method.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsinregion.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache.getobjectsinregion.aspx"&gt;GetObjectsInRegion&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Returns a list of all objects in a region. This method is useful when you do not know all the tags used in the region.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ff424965.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ff424965.aspx"&gt;GetCacheItem&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Returns a &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacacheitem.aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacacheitem.aspx"&gt;DataCacheItem&lt;/A&gt; object. In addition to the cached object and other information associated with the cached object, the &lt;STRONG&gt;DataCacheItem&lt;/STRONG&gt; object also includes the associated tags.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ff424901.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ff424901.aspx"&gt;Add&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;When adding an object to cache, this method supports associating tags with that item in the cache.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ff424971.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ff424971.aspx"&gt;Put&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;When putting an object into cache, this method can be used to replace tags associated with a cached object.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ff424930.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ff424930.aspx"&gt;Remove&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;This method deletes the cached object and any associated tags.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;Managing the data in the cache&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There are a number of methods to get objects out of the cache but logically I like to start in terms of adding to the cache first.&amp;nbsp; So, lets take a look at the put method.&amp;nbsp; The put method will update an object that already has a key that is contained in the cache (whereas the Add will return an exception if the key is already present).&amp;nbsp; The put method can also update or add new tags to an existing object in the cache.&amp;nbsp; As we look at the Put method signature below we can see that this version of the method accepts the key and value just as the other overrides of the Put method do but this one also adds on a collection of tags as well as the name of the region that the cached item will reside in.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; DataCacheItemVersion Put (&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; key,&lt;BR&gt;Object value,&lt;BR&gt;IEnumerable&amp;lt;DataCacheTag&amp;gt; tags,&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; region&lt;BR&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The code below shows how we can use the Put method and include multiple tags&lt;/P&gt;&lt;FONT size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; InsertCacheObjectWithTag(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CacheName, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; RegionName)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;//This can also be kept in a config file&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (dcf != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; tags = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Wine"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;),&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Red"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;),&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Merlot"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dataCache = dcf.GetCache(CacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataCache.Put(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"WineKey"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"WineValue"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, tags, RegionName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Now we can look at the methods to retrieve objects.&amp;nbsp; There are four main Get methods.&amp;nbsp; We can get by tag, any tag, all tags and finally any object that exists in the region no matter what tag.&amp;nbsp; The GetObjectsInRegion method is what provides us the ability to implement a scenario in which all cached objects are related and can be treated as a group.&amp;nbsp; The related data can also be removed by called dataCache.RemoveRegion(RegionName) just as we called the CreateRegion method above.&lt;/P&gt;
&lt;P&gt;For people that have been working with Memcached you can delete dependent data through the cas (check and set) operation.&amp;nbsp; The reason that I bring this up is that more people are familiar with Memcached and therefore I am asked if AppFabric Caching has this or that functionality.&amp;nbsp; What I am finding is that it has the same functionality and more.&amp;nbsp; It is just implemented a bit differently.&lt;/P&gt;
&lt;P&gt;Anyways, if we want to retrieve all the objects in the cache that have a Wine tag we can use the GetObjectsByTag as shown below:&lt;/P&gt;&lt;FONT size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;public&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;IEnumerable&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;KeyValuePair&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;object&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt;&amp;gt; GetLookUpCacheDataByTag(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; TagValue)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cache = dcf.GetCache(cacheName);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dct = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheTag&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(TagValue);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;return&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cache.GetObjectsByTag(dct, regionName);&amp;nbsp; //regionName could either be passed in or an internal variable&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;and lastly, we can remove items based on a tag.&amp;nbsp; I already mentioned that we can call the RemoveRegion method to remove all the related data that is grouped together in a region.&amp;nbsp; If there is a specific item that you want removed then you can call the Remove method and pass in the key.&amp;nbsp; If you wanted to delete based on a tag value then you would have to call one of the GetXXX methods, obtain the key, and then call the Remove method by passing the returned key value.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10001250" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Pre-Populate the AppFabric Cache</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/04/07/pre-populate-the-appfabric-cache.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/04/07/pre-populate-the-appfabric-cache.aspx</id><published>2010-04-07T19:22:00Z</published><updated>2010-04-07T19:22:00Z</updated><content type="html">&lt;P&gt;When I start talking to people about the caching functionality that is part of Windows Server AppFabric I am usually asked "What is the AppFabric Cache?"&amp;nbsp; The MSDN page at &lt;A href="http://msdn.microsoft.com/en-us/library/ee790954.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee790954.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee790954.aspx&lt;/A&gt; provides a great overview (below) as well as additional information.&amp;nbsp; The Cache is defined as:&lt;/P&gt;
&lt;P&gt;"Windows Server AppFabric caching features use a cluster of servers that communicate with each other to form a single, unified application cache system. As a distributed cache system, all cache operations are abstracted to single point of reference, referred to as the cache cluster. In other words, your client applications can work with a single logical unit of cache in the cluster regardless of how many computers make up the cache cluster. "&lt;/P&gt;
&lt;P&gt;When you develop against the AppFabric Cache you utilize the cache-aside pattern.&amp;nbsp; This pattern outlines the steps in which the application will first check to see if the data is in the cache.&amp;nbsp; If not, then query a database (or other data source), load the cache, then return the value.&amp;nbsp; The idea is that the cache will be populated over time as instances of the application call for data.&amp;nbsp; The AppFabric Cache comes with a number of options around how long data should remain in the cache and provides you the flexibility to tune the performance to your needs.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;One thing that the cache-aside pattern doesn't provide for is the pre-population of data in the cache.&amp;nbsp; This entry will walk through how we can provide this functionality.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The first thing we need to do is to create the cache.&amp;nbsp; I outline how to create a cache in .NET code in my previous &lt;A href="http://blogs.msdn.com/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx" mce_href="http://blogs.msdn.com/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx"&gt;entry&lt;/A&gt;.&amp;nbsp; You can check that out but I will also include the code in the sample below.&amp;nbsp; As you go about creating the cache you also need to decide if you want eviction to occur and if so how long the data will stay in the cache until it is evicted.&amp;nbsp; For this example I am going to setup the cache so that eviction is turned off (Expirable is set to false).&amp;nbsp; Since I am preloading the cache I want to the data to remain in the cache.&amp;nbsp; If I read your mind, the next question will be how will the code handle when new data is entered into the database.&amp;nbsp; Through the use of the SQL Dependency functionality we can setup an event handler to respond when an event is raised when there is a change at the database layer.&amp;nbsp; Once this event is caught we can empty the cache and reload it.&amp;nbsp; We could also add code to take advantage of the cache-aside pattern and if we don't the data in the cache then query the database and populate the cache on demand.&lt;/P&gt;
&lt;P&gt;As we look at the code example below lets jump directly to the &lt;FONT size=2 face=Consolas&gt;PopulateLookUpCache&lt;/FONT&gt; method.&amp;nbsp; The first part of this method sets up the database connection, the SQL Dependency and loads the data into a dataset.&amp;nbsp; The second part of the method focuses on the loading of the cache.&amp;nbsp; This is the part that we will focus on.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Before we can use the cache we need to create an instance of the DataCacheFactory. This object requires configuration information.&amp;nbsp; This can either be through entries in a config file as shown below:&amp;nbsp;&lt;/P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;dataCacheClient&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;hosts&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;host&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;AppFabricBeta2&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;cachePort&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;22233&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;hosts&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;localCache&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;isEnabled&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;true&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;sync&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;TTLBased&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;objectCount&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;100000&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;ttlValue&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;300&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; /&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;dataCacheClient&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;or through code by creating a DataCacheFactoryConfiguration object and passing it to the DataCacheFactory as shown below:&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;};&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;We can now call the GetCache method which will return a cache object based on the name of the cache that is passed into the method.&amp;nbsp; The Cache object has a number of &lt;A href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache_members(WS.10).aspx" mce_href="http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacache_members(WS.10).aspx"&gt;methods&lt;/A&gt; which allow us to interact with the cache.&amp;nbsp; I use the Put method as the Put will add or replace an object in the cache whereas the Add method only adds an entry.&amp;nbsp; If there is already an object in the cache it will return an exception.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;In the code below, I loop through the DataSet and call the Put method to populate the cache.&amp;nbsp; The Put method takes two parameters.&amp;nbsp; The first is the key that will be used and the second is the value.&amp;nbsp; In this case, since I am using the AdventureWorks sample database, the Products table contains the product id and the product which works very nicely for this example.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Once the loop has been executed and the data is now in the cache we can double check that the cache has been populated through the use of a PowerShell cmdlet.&amp;nbsp; Switch to a PowerShell command window and type in (without the quotes) "Get-CacheStatistics -CacheName &amp;lt;your cache name&amp;gt;" and hit enter.&amp;nbsp; This will return a list of attributes related to the cache and will show you how many items are currently in the cache.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We now have a populated cache and a now can use the &lt;FONT size=2 face=Consolas&gt;GetLookUpCacheData&lt;/FONT&gt; method to read data out of the cache for our application.&amp;nbsp; Take a look at the code below to see how all of this was done as well as how to setup the SQL Dependency code to get events.&amp;nbsp;&amp;nbsp; As always this code is provided as is and there are a number of places that should be refactored - such as the repeating DataCacheFactory objects.&lt;/P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;
&lt;P&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Collections.Generic;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Linq;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Text;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Data.SqlClient;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Data;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; Microsoft.ApplicationServer.Caching;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Management.Automation;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;using&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; System.Management.Automation.Runspaces;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;namespace&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; AppFabricCacheWrapper&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;public&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;class&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CacheHelper&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; : &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;IDisposable&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;static&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataSet&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; lookUpDataset = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; connString = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.Empty;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cacheName = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"PreLoadSampleCache"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;public&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CacheHelper()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connString = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Data Source=(local);Initial Catalog=AdventureWorksLT;Integrated Security=SSPI;"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDependency&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.Start(connString);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CreateCache(cacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PopulateLookUpCache(cacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~CacheHelper()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDependency&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.Stop(connString);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dispose(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;false&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;public&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; Dispose()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dispose(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;true&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;GC&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.SuppressFinalize(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;this&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;protected&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;virtual&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; Dispose(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;bool&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; disposing)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; GetLookUpCacheData(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; keyValue) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cache = dcf.GetCache(cacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; data = cache.Get(keyValue) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;as&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (data == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;//Determine if you are going to query the database&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;return&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; data;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;lt;summary&amp;gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; Retrieves look up data for the given key and type from database&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;lt;/summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; PopulateLookUpCache(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CacheName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlConnection&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; conn = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlCommand&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; comm = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlCommand&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; commDependency = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDataAdapter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; sqlAdapter = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //populate DataSet &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;{ &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Connect to look up database and retrieve the names of the products. &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;conn = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlConnection&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(connString); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn.Open(); &lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlCommand&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm.Connection = conn; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm.CommandText = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"select ProductID, Name from SalesLT.Product"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm.CommandType = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CommandType&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.Text; &lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (lookUpDataset == &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lookUpDataset = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataSet&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;else &lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lookUpDataset.Clear(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlAdapter = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDataAdapter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(comm);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlAdapter.Fill(lookUpDataset);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;//Command object used for subscribing to notifications &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlCommand&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency.Connection = conn;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency.CommandText = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"select ProductID, Name from SalesLT.Product"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency.Notification = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDependency&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dependency = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlDependency&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(commDependency);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dependency.OnChange += &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;OnChangeEventHandler&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(dependency_OnChange);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency.ExecuteNonQuery();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;catch&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Exception&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;throw&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Exception&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(e.Message + e.StackTrace);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;finally&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PBR &lt;br&gt;sqlAdapter.Dispose();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comm.Dispose();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commDependency.Dispose();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn.Close();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn.Dispose();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //populate cache&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;try&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;//This can also be kept in a config file&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (dcf != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cache = dcf.GetCache(CacheName);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataRow&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; product &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;in&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; lookUpDataset.Tables[0].Rows)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cache.Put(product[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"ProductID"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;].ToString(), product[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Name"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;].ToString());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Exception&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;throw&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Exception&lt;/FONT&gt;&lt;FONT size=2 face=Consolas p e.StackTrace);&lt; + (e.Message&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; Event which will be fired when there are any database changes done to the dependency query set&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ///&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2 face=Consolas&gt;&amp;lt;/summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dependency_OnChange(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;object&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; sender, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlNotificationEventArgs&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (e.Info != &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;SqlNotificationInfo&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.Invalid)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PopulateLookUpCache(cacheName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void(&lt;/FONT&gt;&lt;FONT size=2 face=Consolas font CreateCache(&lt;&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CacheName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;//This can also be kept in a config file&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (dcf != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; state = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;InitialSessionState&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.CreateDefault();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.ImportPSModule(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;[] { &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"DistributedCacheAdministration"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"DistributedCacheConfiguration"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; });&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.ThrowOnRunspaceOpenError = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;true&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; rs = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;RunspaceFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.CreateRunspace(state);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rs.Open();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; pipe = rs.CreatePipeline();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pipe.Commands.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Command&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Use-CacheCluster"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;));&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cmd = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Command&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"New-Cache"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CommandParameter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Name"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, CacheName));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CommandParameter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Expirable"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;false&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pipe.Commands.Add(cmd);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; output = pipe.Invoke();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9991952" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Interview on Endpoint.TV</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/04/01/interview-on-endpoint-tv.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/04/01/interview-on-endpoint-tv.aspx</id><published>2010-04-01T18:58:00Z</published><updated>2010-04-01T18:58:00Z</updated><content type="html">&lt;P class=MsoNormal&gt;&lt;A href="http://blogs.msdn.com/dannyg/" mce_href="http://blogs.msdn.com/dannyg/"&gt;Danny Garber&lt;/A&gt; and I were interviewed for Endpoint.TV on Windows Server AppFabric and our upcoming book.&lt;/P&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;The interview has been published and is now available.&amp;nbsp; Check it out at &lt;A href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Pro-Windows-Server-AppFabric/" mce_href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Pro-Windows-Server-AppFabric/"&gt;http://channel9.msdn.com/shows/Endpoint/endpointtv-Pro-Windows-Server-AppFabric/&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9989071" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Calling PowerShell from .NET</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/03/31/calling-powershell-from-net.aspx</id><published>2010-03-31T20:08:00Z</published><updated>2010-03-31T20:08:00Z</updated><content type="html">&lt;P&gt;I have been working with Windows Server AppFabric caching lately and have found it to be very impressive.&amp;nbsp; The more that I work with it the more that I can see areas that it can be utilized.&amp;nbsp; One of the things that will become quite evident as you start using it is that much of the setup and configuration is done through PowerShell cmdlets.&lt;/P&gt;
&lt;P&gt;I am in the process of putting together an application and I want the application to be able to create and pre-populate the cache.&amp;nbsp; As I looked into creating the cache I knew that it could be created through PowerShell directly but I wanted to call the PowerShell cmdlets from .NET.&amp;nbsp; So, lets look at what is needed to create the cache from PowerShell first and then we will look at the code to call the cmdlets from .NET.&lt;/P&gt;
&lt;P&gt;This assumes that AppFabric has been installed and configured.&lt;/P&gt;
&lt;P&gt;Open a PowerShell command window.&amp;nbsp; The first thing that we are going to do is to import two modules and then we can start issuing commands.&amp;nbsp; First, type "Import-Module DistributedCacheAdministration" (without the quotes) and hit enter.&amp;nbsp; This will import the cache administration cmdlets. Next type "Import-Module DistributedCacheConfiguration" and hit enter.&amp;nbsp; This will import the cache configuration cmdlets.&lt;/P&gt;
&lt;P&gt;The next command will bring the current machines' cluster configuration into the PowerShell session context.&amp;nbsp; So, type in Use-CacheCluster and hit enter.&amp;nbsp; We have now entered all that we need to start interacting with the cache.&amp;nbsp; The first thing that we need to do is to ensure that the cache service is running.&amp;nbsp; Type "Get-CacheHost" and hit enter.&amp;nbsp; Look on the screen and see if the Service Status show UP.&amp;nbsp; If it shows DOWN then issue the following commands to start it.&amp;nbsp; Type "$hostinfo = Get-CacheHost" and hit enter.&amp;nbsp; Then type in "Start-CacheHost $hostinfo.HostName $hostinfo.PortNo". &lt;/P&gt;
&lt;P&gt;At this point we are ready to create the cache using the New-Cache cmdlet.&amp;nbsp; Type "New-Cache &amp;lt;your cache name here&amp;gt;" and hit enter.&amp;nbsp; This will create a cache with your name that is ready to use.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;If you want to see the configuration for your newly created cache type in "Get-CacheConfig &amp;lt;your cache name here&amp;gt;" and hit enter.&amp;nbsp; You will see the following configuration attributes and their settings.&lt;/P&gt;
&lt;P&gt;CacheName : MyCache&lt;BR&gt;TimeToLive : 10 mins&lt;BR&gt;CacheType : Partitioned&lt;BR&gt;Secondaries : 0&lt;BR&gt;IsExpirable : False&lt;BR&gt;EvictionType : LRU&lt;BR&gt;NotificationsEnabled : False&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this all with code we need to add three references to our project.&amp;nbsp; Add the System.Management.Automation assembly as well as the Microsoft.ApplicationServer.Caching.Core and Microsoft.ApplicationServer.Caching.Client assemblies.&amp;nbsp; These two assemblies can be found in the Windows\System32\AppFabric directory.&lt;/P&gt;
&lt;P&gt;To set up the environment in .NET to issue PowerShell commands we need to start with the InitialSessionState class.&amp;nbsp; This will create a session with the PowerShell runspace.&amp;nbsp; A PowerShell runspace is the operating environment where you can create pipelines which will run the cmdlets.&lt;/P&gt;
&lt;P&gt;So, just as above we will need to start with importing the DistributedCacheAdministration and DistributedCacheConfiguration modules.&amp;nbsp; This can be seen below in the source code with the state.&lt;A href="http://msdn.microsoft.com/en-us/library/system.management.automation.runspaces.initialsessionstate.importpsmodule(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.management.automation.runspaces.initialsessionstate.importpsmodule(VS.85).aspx"&gt;ImportPSModule&lt;/A&gt; method.&amp;nbsp; Once we have the session state created we can call the RunspaceFactory to create a new runspace.&amp;nbsp; At this point we can call the Open method can now start creating commands through a pipeline.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;In the code below we create two pipelines.&amp;nbsp; The first is our Use-CacheCluster command.&amp;nbsp; This is a command that doesn't take or return any arguments.&amp;nbsp; The next command is the New-Cache command.&amp;nbsp; This takes a set of arguments so we will create this a bit different.&amp;nbsp; First, we will create a Command object and then set parameters on the command object for each of the arguments we want to pass in.&amp;nbsp; In this example I am providing a name as well as telling the caching system that I don't want the cache items to expire.&amp;nbsp; Next, we need to pass the command object to the pipe and lastly, call the Invoke method as shown in the code below:&amp;nbsp; &lt;/P&gt;&lt;FONT size=2 face=Consolas&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;private&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;void&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; CreateCache(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cacheName)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //This can also be kept in a config file&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; config = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactoryConfiguration&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Servers = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;List&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheServerEndpoint&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Environment&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.MachineName, 22233)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; dcf = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;DataCacheFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(config);&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; (dcf != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;null&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; state = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;InitialSessionState&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.CreateDefault();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.ImportPSModule(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;string&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;[] { &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"DistributedCacheAdministration"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"DistributedCacheConfiguration"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; });&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.ThrowOnRunspaceOpenError = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;true&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; rs = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;RunspaceFactory&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;.CreateRunspace(state);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rs.Open();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; pipe = rs.CreatePipeline();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pipe.Commands.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Command&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Use-CacheCluster"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;));&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; cmd = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;Command&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"New-Cache"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CommandParameter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Name"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, cacheName));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;new&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2 face=Consolas&gt;CommandParameter&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;"Expirable"&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;false&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pipe.Commands.Add(cmd);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt; output = pipe.Invoke();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;We now have a cache created for us from .NET code.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9988344" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Twin Cities Connected Systems User Group Meeting - March 11th, 2010</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/03/10/twin-cities-connected-systems-user-group-meeting-march-11th-2010.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/03/10/twin-cities-connected-systems-user-group-meeting-march-11th-2010.aspx</id><published>2010-03-10T15:08:00Z</published><updated>2010-03-10T15:08:00Z</updated><content type="html">&lt;P&gt;If you are in are in Minneapolis on Thursday March 11th please join us for the Twin Cities Connected Systems User Group Meeting.&lt;/P&gt;
&lt;P&gt;The meeting takes place at 6:00 p.m. at the Microsoft offices at 8300 Norman Center Drive, Bloomington, MN 55437.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I will be speaking on How to Create Windows Server AppFabric Applications&lt;/P&gt;
&lt;P&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;Here is a write-up of what will be covered:&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;You have heard about Dublin, now called Windows Server AppFabric, but do you know what it is and what it includes?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know how to create WCF and WF applications/services that work better with AppFabric?&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Come to the user group meeting and see how to write these applications and take advantage of AppFabric.&amp;nbsp; We will show you how to use Visual Studio 2010 to create WCF and WF services and how to deploy, monitor, and control them with Windows Server AppFabric.&amp;nbsp; In addition, we will also talk about what you need to know to start using AppFabric and what you need to do to optimize your existing applications and services to begin using AppFabric.&lt;SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9976233" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="BTS User Group" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BTS+User+Group/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Pro Windows Server AppFabric Book</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/01/18/pro-windows-server-appfabric-book.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/01/18/pro-windows-server-appfabric-book.aspx</id><published>2010-01-18T22:40:00Z</published><updated>2010-01-18T22:40:00Z</updated><content type="html">&lt;P&gt;I have been spending my free time working on my next book.&amp;nbsp; &lt;A href="http://blogs.msdn.com/dannyg/" mce_href="http://blogs.msdn.com/dannyg/"&gt;Danny Garber&lt;/A&gt; and I are co-authoring this &lt;A href="http://www.apress.com/book/view/1430228172" mce_href="http://www.apress.com/book/view/1430228172"&gt;book&lt;/A&gt; from APress.&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://blogs.msdn.com/photos/skaufman/images/9948637/original.aspx" width=240 height=240 mce_src="http://blogs.msdn.com/photos/skaufman/images/9948637/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;The book will be available this spring and should coincide with the release of AppFabric.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9950032" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Twin Cities Connected Systems User Group Meeting - January 21st, 2010</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2010/01/14/twin-cities-connected-systems-user-group-meeting-january-21st-2010.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2010/01/14/twin-cities-connected-systems-user-group-meeting-january-21st-2010.aspx</id><published>2010-01-14T21:09:00Z</published><updated>2010-01-14T21:09:00Z</updated><content type="html">&lt;P&gt;If you are in are in Minneapolis on Thursday January 21st please join us for the Twin Cities Connected Systems User Group Meeting.&lt;/P&gt;
&lt;P&gt;The meeting takes place at the Microsoft offices at 8300 Norman Center Drive, Bloomington, MN 55437.&amp;nbsp; This months meeting time has changed and we will be meeting&amp;nbsp;from 5:00 to 6:30&lt;/P&gt;
&lt;P&gt;Ed Jones from RBA will be presenting on Implementing a Service Bus Architecture with BizTalk 2009 and the BizTalk ESB Toolkit 2.0: A Real World Example&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;&lt;o:p&gt;Here is a write-up of what will be covered:&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;Although BizTalk Server offers much in terms of flexibility and extensibility through the implementation of Service Oriented Architectures, most BizTalk applications are developed in “hub-and-spoke” models that are tightly coupled to specific points of functionality.&amp;nbsp; Entire business processes are often represented as orchestration.&amp;nbsp; As such, when business processes change, orchestrations also need to change, often requiring the reconstruction and redeployment of entire BizTalk solutions.&lt;/P&gt;
&lt;P&gt;One way to alleviate this pain is to avoid the use of a “hub-and-spoke” model altogether in favor of a Service Bus approach.&amp;nbsp; The BizTalk ESB Toolkit helps accomplish this by making the creation of a true Service Bus easier.&amp;nbsp; One feature of the toolkit for example, itineraries, allows us to create capabilities that are independent of each other and independent of specific processes.&amp;nbsp; This "Composition of Capabilities" method is preferred over the point-to-point solutions used in many BizTalk applications enabling more extensible and flexible Business Processes.&lt;/P&gt;
&lt;P&gt;Our client required a system that would accept incoming shipment data in the form of flat-files in multiple formats, process that data through a series of resolutions, and then output the data in both its raw and processed form into an ERP system.&amp;nbsp; Some data will be processed, while other data will be ignored.&amp;nbsp; Over time it is expected that the various processes may change in size, scope, and sequential order.&amp;nbsp; Our solution implements ESB Toolkit Itineraries to accomplish this composition of capabilities.&amp;nbsp; We also use the Exception Management and other more traditional BizTalk functionalities such as Business Rules.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9948642" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="BTS User Group" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BTS+User+Group/" /></entry><entry><title>AppFabric and BizTalk</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/11/23/appfabric-and-biztalk.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/11/23/appfabric-and-biztalk.aspx</id><published>2009-11-24T05:37:00Z</published><updated>2009-11-24T05:37:00Z</updated><content type="html">&lt;P&gt;There have been lots of questions lately about AppFabric (code named Dublin). These questions have centered around why Microsoft needs another middle tier solution and will AppFabric replace BizTalk.&lt;/P&gt;
&lt;P&gt;Lets take a look at these questions as well as two additional questions; What is AppFabric and why does Microsoft need another middle tier solution? First, AppFabric is a distributed application server. To answer the other questions, we need to go in a little more depth. &lt;/P&gt;
&lt;P&gt;Before .NET was released, developers working with the Microsoft technologies used COM+ to host their middle tier objects. Back then, when we needed to scale out our object oriented and object based applications we created middle tier code libraries and ‘hosted’ them in COM+. The COM+ host provided instance management (just-in-time activation), role-based security, automated transaction management as well as better memory and processor management, distributed transactions and a number of other services.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When .NET was introduced, we moved away from COM components and also moved away from using COM+ as a hosting model. This left a vacuum that so far had gone unfilled. &lt;/P&gt;
&lt;P&gt;In attempts to fill this vacuum, individual developers had to create their own hosts. These hosts typically were Windows Services. However, these services usually didn’t include multi threading, scale out capabilities, tracking, monitoring, etc. – the types of functionality that has been in BizTalk for years. As Microsoft looked at BizTalk, as well as the .NET Framework, it was determined that there are many great features in BizTalk that if a scaled down version was available it would address gaps in the framework. Thus AppFabric was born.&lt;/P&gt;
&lt;P&gt;For .NET developers writing applications using WCF and WF, AppFabric will fill the middle tier hosting vacuum. AppFabric will provide the host and will provide scalability and support for building out your middle tier application components. It also will simplify deployment, configuration, management and scalability of composite applications. The goal of AppFabric is to provide a server infrastructure, on which business logic developed in WF can be executed and exposed via WCF endpoints, without the need to design, develop, and support the infrastructural code.&lt;/P&gt;
&lt;P&gt;The next question I hear is will AppFabric replace BizTalk? The answer is very clearly no. &lt;/P&gt;
&lt;P&gt;AppFabric should be used when your architecture calls for an application level code-first object based approach. This is the same approach that is used by WF and WCF programming models and is the one that can be hosted in AppFabric and the additional functionality that AppFabric provides. AppFabric will provide a number of management and scalability features through IIS and WAS to provide the server infrastructure without the need to write the plumbing as you did before. This is a different approach than that of the XML Schema first approach that is used in BizTalk. &lt;/P&gt;
&lt;P&gt;Use BizTalk when your architecture calls for an enterprise level message based approach. Use BizTalk when you need to isolate disparate systems that need to be connected. In point-to-point integrations, changes made to the provider system can have a profound impact on the consuming application. BizTalk natively provides a hub-based integration model which eases this burden and allows organizations to provide business services that are isolated from the impact of changes made to the systems and processes on which these services are based. This is achieved through the use of separate schemas, and the associated ability to easily develop message transformation logic using BizTalk’s Mapper tool. Use BizTalk if you have business-to-business requirements and need to integrate using technologies such as EDI, SWIFT, RosettaNet, AS2 or HL7.&lt;/P&gt;
&lt;P&gt;The reality is that businesses will utilize both of these technologies in their different application architectures. This is not an either or decision but instead a decision of where and when to use each.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep in mind, however, that many of the same terms are used to describe the functionality provided with both BizTalk and AppFabric. These terms are things like Content Based Routing, Correlation, long running transactions, etc. Although the terms are the same the implementation and functionality is different. With all decisions, make sure that you take a couple of minutes to look under the hood and ensure that you understand the differences. &lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927727" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WF/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /><category term="AppFabric" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/AppFabric/" /></entry><entry><title>Follow Up from TechEd Europe</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/11/20/follow-up-from-teched-europe.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/11/20/follow-up-from-teched-europe.aspx</id><published>2009-11-21T05:46:00Z</published><updated>2009-11-21T05:46:00Z</updated><content type="html">&lt;A href="http://blogs.msdn.com/paolos" mce_href="http://blogs.msdn.com/paolos"&gt;Paolo Salvatori&lt;/A&gt; and I delivered a session titled 'Customizing and Extending the BizTalk WCF Adapters' and Paolo has created a number of fantastic blog entries around this subject.&amp;nbsp; His latest &lt;A href="http://blogs.msdn.com/paolos/archive/2009/11/17/customizing-and-extending-the-biztalk-wcf-adapters.aspx" mce_href="http://blogs.msdn.com/paolos/archive/2009/11/17/customizing-and-extending-the-biztalk-wcf-adapters.aspx"&gt;entry&lt;/A&gt; goes through much of the content that was delivered in the session and he has included a number of links at the bottom for more WCF Adapter information and samples.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9926659" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry><entry><title>Speaking at TechEd Europe 2009</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/10/13/speaking-at-teched-europe-2009.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/10/13/speaking-at-teched-europe-2009.aspx</id><published>2009-10-13T05:02:00Z</published><updated>2009-10-13T05:02:00Z</updated><content type="html">&lt;P&gt;I will be speaking at TechEd Europe 2009 in Berlin Germany November 9th through the 13th.&lt;/P&gt;
&lt;P&gt;I will be presenting two sessions.&amp;nbsp; My first is a 'Deep Dive with Microsoft BizTalk Server 2009 Development Platform' and my second is 'Customizing and Extending the BizTalk WCF Adapters'.&lt;/P&gt;
&lt;P&gt;If you are going to be there stop by and say hello.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9906441" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry><entry><title>The Architecture Journal - Edition 21</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/10/11/the-architecture-journal-edition-21.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/10/11/the-architecture-journal-edition-21.aspx</id><published>2009-10-12T04:28:00Z</published><updated>2009-10-12T04:28:00Z</updated><content type="html">&lt;P&gt;I co-authored an article titled 'Design Considerations for S+S and Cloud Computing' in this months Architecture Journal.&amp;nbsp; I co-authored this along with 8 other architects at Microsoft.&amp;nbsp; They were &lt;A href="http://blogs.msdn.com/fred_chong/" mce_href="http://blogs.msdn.com/fred_chong/"&gt;Fred Chong&lt;/A&gt;, Alejandro Miguel, &lt;A href="http://blogs.msdn.com/thehoggblog/" mce_href="http://blogs.msdn.com/thehoggblog/"&gt;Jason Hogg&lt;/A&gt;, Ulrich Homann, Brant Zwiefel, &lt;A href="http://blogs.msdn.com/dannyg/" mce_href="http://blogs.msdn.com/dannyg/"&gt;Danny Garber&lt;/A&gt;, Joshy Joseph and Scott Zimmerman.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://blogs.msdn.com/photos/skaufman/images/9905991/original.aspx" width=590 height=134 mce_src="http://blogs.msdn.com/photos/skaufman/images/9905991/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Here is the summary: The purpose of this article is to share our thoughts about the design patterns for a new generation of applications that are referred to as &lt;I&gt;Software plus Services&lt;/I&gt;, &lt;I&gt;cloud computing&lt;/I&gt;, or &lt;I&gt;hybrid computing&lt;/I&gt;. The article provides a view into S+S architectural considerations and patterns as they affect common architectural domains such as enterprise, software, and infrastructure architecture.&lt;/P&gt;
&lt;P&gt;Check it out at &lt;A href="http://msdn.microsoft.com/en-us/architecture/aa699439.aspx" mce_href="http://msdn.microsoft.com/en-us/architecture/aa699439.aspx"&gt;http://msdn.microsoft.com/en-us/architecture/aa699439.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also be sure to check out the other great articles in the 21st edition of the &lt;A href="http://msdn.microsoft.com/en-us/architecture/aa699437.aspx" mce_href="http://msdn.microsoft.com/en-us/architecture/aa699437.aspx"&gt;magazine&lt;/A&gt;.&amp;nbsp; This edition is focused on SOA today and tomorrow.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9905994" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>StreamInsight</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/09/29/streaminsight.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/09/29/streaminsight.aspx</id><published>2009-09-30T07:04:00Z</published><updated>2009-09-30T07:04:00Z</updated><content type="html">&lt;P&gt;You are probably asking what is StreamInsight.&amp;nbsp; Well, it is the platform for performing Complex Event Processing (CEP) from Microsoft.&amp;nbsp; Actually to quote exactly what it is - it is a&amp;nbsp;"&lt;SPAN&gt;platform for the continuous and incremental processing of unending sequences of events (event streams) from multiple sources with near-zero latency".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;There has been a need to deal with processing at near zero latency for some time.&amp;nbsp; Many times existing products can perform at low latency and that has been acceptable, however, there are a number of situations where low latency wasn't sufficient.&amp;nbsp; That is where Complex Event Processing comes in.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;According to Wikipedia CEP is defined as:&amp;nbsp; primarily an event processing concept that deals with the task of processing multiple events with the goal of identifying the meaningful events within the event cloud. CEP employs techniques such as detection of complex patterns of many events, event correlation and abstraction, event hierarchies, and relationships between events such as causality, membership, and timing, and event-driven processes.&amp;nbsp; CEP is to discover information contained in the events happening across all the layers in an organization and then analyze its impact from the macro level as "complex event" and then take subsequent action plan in real time.&lt;/P&gt;
&lt;P&gt;Some of the scenarios that call for CEP are:&lt;/P&gt;
&lt;P&gt;Manufacturing: Sensors on the plant floor capturing data through device controllers and aggregating data consisting of tens of thousands of events per second with requirements to act on patterns detected to ensure product quality &lt;/P&gt;
&lt;P&gt;Web analytics: Instrument server to capture click-stream data and determine online customer behavior &lt;/P&gt;
&lt;P&gt;Financial services: Listening to data feeds like news or stocks. Use that data to run queries looking for patterns that find opportunities to buy or sell stock&lt;/P&gt;
&lt;P&gt;Some of the features of StreamInsight listed on the download site are: &lt;/P&gt;&lt;SPAN&gt;
&lt;UL&gt;
&lt;LI&gt;Derive meaningful and relevant information from data/events streams through complex patterns. These patterns can be defined using a declarative query paradigm based on well-defined streaming semantics with LINQ as query language. &lt;/LI&gt;
&lt;LI&gt;For the development of applications, adapters, and analytics, the user can rely on well-established and powerful development frameworks and tools such as .NET, LINQ, and Microsoft Visual Studio. &lt;/LI&gt;
&lt;LI&gt;The platform integrates with various data sources and sinks through input and output adapters. The framework to build domain-specific adapters utilizes a .NET API to make adoption of the platform easy. Independence between adapters and queries facilitates seamless integration of real-time and historical analysis. &lt;/LI&gt;
&lt;LI&gt;The platform architecture supports a variety of deployment options, from scenarios with a low-footprint embedded option to high-end server deployments. &lt;/LI&gt;
&lt;LI&gt;A rich set of manageability features such as a management interface, a diagnostic interface and a debugging tool are provided as part of the platform. &lt;/LI&gt;&lt;/UL&gt;&lt;/SPAN&gt;
&lt;P&gt;You can start working with the CTP by downloading it at: &lt;A href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=a3faa562-b6dc-4702-90c6-bf8e08df3b8b" mce_href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=a3faa562-b6dc-4702-90c6-bf8e08df3b8b"&gt;http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=a3faa562-b6dc-4702-90c6-bf8e08df3b8b&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901132" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry><entry><title>WCF:  Did you know?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/skaufman/archive/2009/08/12/wcf-did-you-know.aspx" /><id>http://blogs.msdn.com/b/skaufman/archive/2009/08/12/wcf-did-you-know.aspx</id><published>2009-08-13T01:15:00Z</published><updated>2009-08-13T01:15:00Z</updated><content type="html">&lt;P&gt;Did you know that when doing contract first development and utilize a Boolean data type with a default value (lets just say the default value was set to true), WCF will not serialize out the default value in the message.&amp;nbsp; WCF will only serialize out the value if it differs from the default.&lt;/P&gt;
&lt;P&gt;This was an interesting scenario in BizTalk when we were trying to test for the Boolean to be true and we saw that it was actually empty.&lt;/P&gt;
&lt;P&gt;Sometimes I wonder with these types of issues if I am the only one in the world that didn't know that.&amp;nbsp; I am going to make the assumption that this will be news to more people then just me.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9867284" width="1" height="1"&gt;</content><author><name>Stephen Kaufman</name><uri>http://blogs.msdn.com/skaufman/ProfileUrlRedirect.ashx</uri></author><category term="BizTalk" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/BizTalk/" /><category term="WCF" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/WCF/" /><category term=".NET" scheme="http://blogs.msdn.com/b/skaufman/archive/tags/-NET/" /></entry></feed>