SendMSMQMessage (BizTalk Server Sample)
The SendMSMQMessage sample demonstrates how to send a message to a BizTalk Message Queuing port from a .NET-based application. It also provides instructions about how to configure Microsoft BizTalk Server 2004 to use BizTalk Message Queuing receive locations.
You can use the code in the simple graphical application included with this sample as an example of how to send messages to BizTalk Message Queuing receive locations within BizTalk Server from .NET-enabled applications such as Microsoft Office, from ASP.NET pages, and so on.
Note For important information about all samples in this SDK, see Samples.
To download the updated BizTalk Server 2004 SDK, go to http://go.microsoft.com/fwlink/?LinkId=24723.
Location in SDK
<Samples Path>\Adapters\SendMSMQMessage\
File Inventory
The following table shows the files in this sample and describes their purpose.
| File(s) | Description |
|---|---|
| App.ico, AssemblyInfo.cs, SendMSMQMessage.csproj, SendMSMQMessage.sln | Provides project, solution, and related files for the simple graphical application for this sample. |
| Form1.cs, Form1.resx | Provides Microsoft Visual C# .NET source and form files for the simple graphical application for this sample. |
To Build and Initialize This Sample
Use the following procedure to build and initialize the SendMSMQMessage sample.
- Confirm that Message Queuing (MSMQ) is installed, and if not, install it.
Important Side-by-side installation of BizTalk Server
2004 and Message Queuing is supported; however, this sample is intended for use when BizTalk Server2004 and Message Queuing are installed on separate computers. For more information, see BizTalk Message Queuing Adapter Security Recommendations. - Build the sample executable.
- Configure BizTalk Server, preferably on a different computer than the one on which you intend to run this sample.
To use the Windows Component Wizard to confirm the installation of Message Queuing
- Click Start, click Control Panel, click Add or Remove Programs, and then click Add/Remove Windows Components.
- In the Components box, verify that Message Queuing is installed.
To build the sample executable
- Open the solution file SendMSMQMessage.sln using Visual Studio .NET 2003.
- On the Build menu, click Build Solution.
To configure BizTalk Server
- Install BizTalk Server 2004 on a different computer than the one on which you intend to run this sample.
Important Side-by-side installation of BizTalk Server
2004 and Message Queuing is supported, however, this sample is intended for use when BizTalk Server2004 and Message Queuing are installed on separate computers. - Select a folder in which to receive messages. The following steps assume that you have selected C:\Demo\Report, but you can adjust the steps as necessary for another folder.
- Open Visual Studio .NET 2003, and in the View menu, select BizTalk Explorer.
- If necessary, select the correct Configuration database.
- In BizTalk Explorer, right-click Send Ports, and then click Add Send Port.
- In the Create New Send Port dialog box, select Static One-Way Port, and then click OK.
- In the Static One-Way Send Port Properties dialog box, in the Name box, type a name for the send port, such as MySendPort.
- In the folder tree on the left side of the dialog box, select Transport | Primary, and then set the Transport Type property to File.
- For the Address (URI) property, click the ellipsis (…) button to open the File Transport Properties dialog box.
- In the File Transport Properties dialog box, set the Destination Folder property to C:\Demo\Report, keep the default settings for the other properties, and then click OK.
- In the Static One-Way Port Properties dialog box, in the folder tree on the left side of the dialog box, select Send | General, and set the Send Pipeline property to PassThruTransmit (...).
- In the folder tree on the left side of the dialog box, select Filters & Mapping | Filters, and then add a new row by setting Property to BTS.ReceivePortName. Leave the Operator column set to ==, set the Value column to MyReceivePort, and then click OK.
- In BizTalk Explorer, right-click Receive Ports, and then click Add Receive Port.
- In the Create New Receive Port dialog box, click One-Way Port, and then click OK.
- In the One-Way Receive Port Properties dialog box, in the Name box, type a name for the receive port, such as MyReceivePort, and then click OK.
Note This name must be the same name as provided in step 12.
- In BizTalk Explorer, under the newly created receive port, right-click Receive Locations, and then click Add Receive Location.
- In the Receive Location Properties - General Configurations dialog box, in the Name box, type a name for the receive port, such as MSMQReceiveLocation.
- In the Receive Location Properties - General Configurations dialog box, in the folder tree on the left side of the dialog box, if necessary, select Configurations | General, and set the properties on the right side as follows.
Property (Category) Setting Transport Type (General)
MSMQT Address (URI) (General)
Click the ellipsis button (…) to open the MSMQT Transport Properties dialog box. In this dialog box, set Queue Name to Test, and then click OK. Receive Handler (Receive Handler)
Select your default application, normally BizTalkServerApplication. Receive Pipeline (Receive Pipeline)
PassThruReceive (...) - Click OK.
- Right-click your new send port, and then click Enlist.
- Right-click your new send port again, and then click Start.
- Right-click your new receive location, and then click Enable.
BizTalk Server is ready now to work with this sample.
To Run This Sample
Use the following procedure to run the SendMSMQMessage sample.
- In a command window, navigate to the following folder:
<Samples Path>\Adapters\SendMSMQMessage\bin\Debug
- Run the file SendMSMQMessage.exe, which starts the graphical application that comprises the user interface for this sample.
Important In a simple installation, this application cannot run on the same computer that BizTalk Server is running on. This is because the application uses Message Queuing (MSMQ), and this usage conflicts with BizTalk Message Queuing unless both variations of Message Queuing are installed side-by-side.
- In the graphical application, in the BizTalk machine name box, type the name of the computer on which BizTalk Server is running.
- Try the Send Wrapped option:
- Optionally change the text in the Message body box.
- Click Send wrapped.
If the operation succeeds, you will see:
- The word Success in red font in the box immediately above the buttons.
- A file appears in your destination folder C:\Demo\Reports. This file contains the text from the Message body box wrapped in simple XML tags by the .NET message queuing library.
If the operation fails, you will see an error message in the box immediately above the buttons.
- Try the Send Exact option:
- Optionally change the text in the Message body box.
- Click Send exact.
If the operation succeeds, you will see:
- The word Success in red font in the box immediately above the buttons.
- A file appears in your destination folder C:\Demo\Reports. This file contains the text from the Message body box exactly as it appears in the text box.
If the operation fails, you will see an error message in the box immediately above the buttons.
See Also
Adapters (BizTalk Server Samples Folder)
To download updated BizTalk Server 2004 Help from www.microsoft.com, go to http://go.microsoft.com/fwlink/?linkid=20616.Copyright © 2004 Microsoft Corporation.All rights reserved.