MQSSendPipelineComponent (BizTalk Server Sample)
This sample demonstrates how to write a pipeline component that reads a set of MQSeries property values from an XML file and applies them to a message.
This sample is composed of two Visual Studio projects, a pipeline component project and a pipeline project that makes use of the pipeline component.
The following table shows the files in this sample and describes their purpose.
The project and solution files for the pipeline component.
The Visual C#® source file for the pipeline component.
The MQSeries properties read and used by the pipeline component.
The project and solution files for the BizTalk pipeline.
The strong naming key file for the BizTalk pipeline project.
The BizTalk Server pipeline.
To create the application, you must complete the following steps:
Create the folders for the application.
Modify and compile the Visual Studio project for the pipeline component.
Copy the compiled assembly and the header file to the appropriate folders.
Modify the Visual Studio project for the BizTalk Server pipeline.
Compile and deploy the BizTalk Server pipeline project.
Set up a BizTalk Server receive location.
Create a MQSeries queue.
Set up a send port.
Enable the receive location and start the send port.
This procedure creates the appropriate folders for the application.
To create the folders for the application
Create a folder named temp on your C:\ drive if it does not already exist.
Create a folder under the C:\temp directory named Pickup3.
This procedure modifies and compiles the Visual Studio project for the pipeline component.
To modify and compile the project for the pipeline component
Double-click the solution file, SetMQSeriesHeaderPropertyComponent\SetMQSeriesHeaderPropertyComponent.sln to open the solution in Visual Studio.
Double-click the class file CSetMQSeriesHeaderPropertyComponent.cs to open the class file in Visual Studio.
Locate the variable samplesDir, verify that this variable is set to the location C:\temp.
Right-click the solution in the Solution Explorer and click Build. This will compile the project into a dll located in the SetMQSeriesHeaderPropertyComponent\SetMQSeriesHeaderPropertyComponent\bin\Debug\ directory.
This procedure copies the compiled assembly and the header file to the appropriate folders.
To copy the compiled assembly and header file to the appropriate folders
Copy the compiled assembly SetMQSeriesHeaderPropertyComponent.dll to the BizTalk pipeline components folder. The default location for the BizTalk pipeline components folder is drive:\Program Files\Microsoft BizTalk Server 2013 R2\Pipeline Components.
Copy the MQHeader properties file SetMQSMQMDHdrProps.xml to the C:\temp directory.
This procedure modifies the Visual Studio project for the BizTalk Server pipeline.
To modify the project for the BizTalk Server pipeline
In Visual Studio, open the solution by double-clicking the solution file, SetMQSeriesHeaderPropertyPipeline\SetMQSeriesHeaderPropertyPipeline.sln.
Create a strong name key file for the project. To do that, do the following:
Open a Visual Studio Command prompt.
Change directories to <SamplesPath>\AdaptersUsage\MQSeriesAdapter\MQSSendPipelineComponent.
Type the following:
sn -k MQSSendPipelineComponent.snk
Press ENTER. This will create the key file.
- Open a Visual Studio Command prompt.
In Solution Explorer, right-click the project and click Properties to launch Project Designer for the project (in the center window).
In the Project Designer, click Signing tab.
In the right-hand pane, select the Sign the assembly option..
Click drop-down list for the Choose a strong name key file option, and click Browse.
Browse to <SamplesPath>\AdaptersUsage\MQSeriesAdapter\MQSSendPipelineComponent\MQSSendPipelineComponent.snk, click Open.
- In the Project Designer, click Signing tab.
The pipeline component that you created earlier is already added to the Pre-Assemble stage of this pipeline project. If this component was not already added you would need to complete the following steps to add it:
In the Visual Studio IDE, click the Toolbox tab on the left side.
Right-click the Toolbox, and click Choose Items.
In the Choose Toolbox Items dialog box, click the BizTalk Pipeline Components tab, select the Custom Component to Set MQseries header propertiescomponent, and then click OK.
Drag the Custom Component to Set MQseries header propertiescomponent to the Pre-Assemble stage of this pipeline.
- In the Visual Studio IDE, click the Toolbox tab on the left side.
This procedure compiles and deploys the BizTalk Server pipeline project.
To compile and deploy the pipeline project
In the Solution Explorer window, right-click the solution, and then click Deploy Solution. This builds the solution and deploys the assembly to the BizTalk Management database.
Verify the Assembly was deployed to the BizTalk Management database:
Open the BizTalk Administration Console.
Click to expand BizTalk Group [<servername>:<management database>], and then click to expand the Assemblies folder.
The deployed pipeline assembly should be visible under the Assemblies folder.
- Open the BizTalk Administration Console.
This procedure creates a BizTalk Server receive location.
To create the receive location
In the BizTalk Server Administration Console, right-click Receive Ports, point to New, and then click One-way Receive Port.
In the One-way Receive Port Properties dialog box, in the Name box type "MQReply" and click OK.
In the left pane, click Receive Locations tab, and then click New.
In the Receive Location Properties dialog box, in the Name field, type "ReceiveFile".
In the Transport Type box, select FILE.
In the Receive Handler field, select BizTalkServerApplication.
In the Receive pipeline field, select Microsoft.BizTalk.DefaultPipelines.PassThruReceive.
In the Receive folder field, type "C:\temp\Pickup3".
In the File mask field, type "*.*".
Click OK, and then click OK again to exit the Receive Location Properties dialog box.
If you have the required permissions to the MQSeries Server for Windows installation, you can create the MQSeries queue through the adapter dialog boxes, and can skip this next procedure.
If you do not have such access, you can use the following procedure to create the queue using the IBM WebSphere MQ Explorer.
To create a MQSeries queue through the MQSeries Explorer
Click Start, point to Programs, point to IBM WebSphere MQ, and then click WebSphere MQ Explorer.
Double-click Queue Managers, and then double-click the default queue manager. The default queue manager is typically named QM_<machine_name> where machine_name is the name of your computer.
Right-click Queues, point to New, and then click Local Queue.
In Create Local Queue dialog box, in Queue Name, type SETHEADER, and then click OK.
This procedure creates the send port for the output message. The MQSeries queue is also created when you create the send port if you have not already created it.
To create the send port and MQSeries queue
Right-click Send Ports, point to New, and then click Static One-way Send Port.
In the Send Port Properties dialog box, in the Name box, type "MQSolicitResponse".
In the Transport Type box, select MQSeries.
In the Send pipeline box, select SetMQSeriesHeaderPropertyPipeline.SetMQSeriesHeadersSendPipeline.
In Filters, add a new entry with the following name/value pairs:
Set Property to "BTS.ReceivePortName".
Set Operator to "==".
Set Value to "ReceiveFile".
Note This sets the send port to subscribe to messages that arrive on the ReceiveFile receive port.
- Set Property to "BTS.ReceivePortName".
In the Address (URI) field, click the ellipsis (…) button.
In the MQSeries Transport Properties dialog box, in the Queue Definition field, click the ellipsis (…) button.
In the Queue Definition dialog box, in the Server Name field, type your computer name.
In the Queue Manager field, select the default queue manager.
In the Queue field, type "SETHEADER", and then click Export.
In the Export dialog box, click Create Queue, and then click OK or Done until you have exited all dialog.
This procedure enables the receive location and start the send port.
To enable the receive location and start the send port
In the BizTalk Server Administration console, click Receive Ports.
In the details pane, right-click the MQIn receive location and click Enable.
In the details pane, right-click the SetMQHeader send port and click Start.
This procedure tests the application.
To test the application
Put a file into the C:\Temp\Pickup3 folder.
Launch the WebSphere MQ Explorer and double-click the SETHEADER queue to examine the message(s) in the SETHEADER queue.
To see all of the context properties for the messages in the SETHEADER queue, complete the following steps:
Double-click the SETHEADER queue to display the Message Browser dialog box.
In the Message Browser dialog box, click Columns to display the Show/Hide Columns for Messages dialog box.
Under Available Columns, double-click each entry to make it visible in the Message Browser dialog box, and then click OK.
- Double-click the SETHEADER queue to display the Message Browser dialog box.
The message context properties for each message should be visible in the Message Browser dialog box.
© 2014 Microsoft Corporation. All rights reserved.