This sample demonstrates the usefulness of ReceiveContext-enabled WCF channels. The sample implements a service to find the product of two numbers using a NetMSMQ channel.
The ReceiveContext class enables an application to decide whether to access the message or leave it in the queue for further processing, even after the contents of the message have been inspected. In this sample, a client sends random integers to a transactional queue. The
ProductCalculator service receives the messages and inspects the message contents, which are integers, to determine whether the product can be computed. If the service operation does not compute the product, the message is put back into the queue and can be received again by the service listening on the queue.
The samples may already be installed on your computer. 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:
To use this sample
Ensure that Microsoft Message Queuing (MSMQ) is installed.
To install MSMQ on Windows Server 2008:
In Server Manager, click Features.
In the right pane under Features Summary, click Add Features.
In the resulting window, expand Message Queuing.
Expand Message Queuing Services.
Click Directory Services Integration (for computers joined to a domain), and then click HTTP Support.
Click Next, and then click Install.
To install MSMQ on Windows Vista:
Open Control Panel.
Click Programs and then, under Programs and Features, click Turn Windows Features on and off.
Expand Microsoft Message Queue (MSMQ) Server, expand Microsoft Message Queue (MSMQ) Server Core, and then select the check boxes for the following Message Queuing features to install:
Message Queuing Server
MSMQ Active Directory Domain Services Integration (for computers joined to a domain)
MSMQ HTTP Support
If you are prompted to restart the computer, click OK to complete the installation.
Ensure that Visual Studio 2012 is installed on the computer.
Using Visual Studio 2012, open the ReceiveContextProductGenerator.sln solution file.
To build the solution, press CTRL+SHIFT+B.
To run the solution, press CTRL+F5.