LINQ Message Query Correlation

This sample demonstrates how to do content-based correlation using a custom MessageQuery implementation as opposed to the system-provided XPathMessageQuery.


Custom MessageQuery, Content-Based Correlation.


This sample shows how to extend from the MessageQuery base class for the purposes of correlation. The custom implementation, LinqMessageQuery, allows users to provide an XName to find within the message using XLinq. The data retrieved by the query is used to form the correlation key to dispatch messages to the appropriate workflow instance.

To set up, build, and run the sample

  1. This sample exposes a workflow service using HTTP endpoints. To run this sample, proper URL ACLs must be added (see Configuring HTTP and HTTPS for details), either by running Visual Studio as Administrator or by executing the following command at an elevated prompt to add the appropriate ACLs. Ensure that your Domain and Username are substituted.

    netsh http add urlacl url=http://+:8000/ user=%DOMAIN%\%UserName%  
  2. Once the URL ACLs are added, use the following steps.

    1. Build the solution.

    2. Set multiple start-up projects by right-clicking the solution and selecting Set Startup Projects. Add Service and Client (in that order) as multiple start-up projects.

    3. Run the application. The client console shows a workflow sending an order and receiving the purchase order id and then subsequently confirming the order. The Service window will show the requests being processed.


The samples may already be installed on your machine. Check for the following (default) directory before continuing.


If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.