![]() |
Enterprise Systems »
Microsoft BizTalk Server »
General
Intermediate
How to create a self-routing message using Dynamic Ports in BizTalk Server 2004By Naveen KaramchettiThis article describes how to create a self-routing message using Dynamic Ports in BizTalk Server 2004. |
C#, XML, Windows, .NET, Visual Studio, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Consider a situation where a BizTalk message itself will have the routing information for the message. In such cases, one needs to create a Dynamic Port. In a Dynamic Port, the destination location is specified during runtime. This feature of Ports comes in very handy when one has to make routing decisions at runtime based on the content of the message.
A custom message "message.xsd" has the following properties:
ID - Holds an integer value used to categorize a message.
Data - The contents of the message.
Destination - Holds the routing information for the message.
Initiator - Specifies the initiator of the message. Let us set some rules based on the "ID" property of the message.
Create a new BizTalk Server Project in Visual Studio .NET.
Step 1: In the Visual Studio .NET menu, select File -> New -> Project, and type the name "DynamicFilePorts".Step 2: Right-click on the project in the Solution Explorer, and select the "Add New Item" option. Then, select the item "Schema" and name it "Message". When the schema shows up, rename the "Root" element to "Message". After that, create the child elements: "ID", "Data", "Destination" and "Initiator".
Message Schema Elements
| Element Name | Element Type |
ID |
xs:int |
Data |
xs:string |
Destination |
xs:string |
Initiator |
xs:string |
Please refer to the image below and confirm your schema file...
This Orchestration would have just three shapes, a Receive shape, an Expression shape, and a Send shape.
Step 3: Right-click on the project in the Solution Explorer, and select the "Add New Item" option. Then, select the item "BizTalk Orchestration" and name it "DynamicPortsDemo".
Step 4: Place the three shapes on the "Orchestration Surface".
Step 5: Create a message.
Step 6: Setting Properties for all the shapes.
Activate" as True.
// Instantly process the message.
if (IncomingMessage.ID >= 200 && IncomingMessage.ID <= 299)
{
OutputDataPort(Microsoft.XLANGs.BaseTypes.Address) =
"FILE://C:/BiztalkProjects/DynamicFilePorts/" +
IncomingMessage.Destination +
"/HighPriorityMessage_%MessageID%.xml";
}
// Low Priority message processing.
else if (IncomingMessage.ID >= 300 &&
IncomingMessage.ID <= 399)
{
OutputDataPort(Microsoft.XLANGs.BaseTypes.Address) =
"FILE://C:/BiztalkProjects/DynamicFilePorts/" +
IncomingMessage.Destination +
"/LowPriorityMessage_%MessageID%.xml";
}
// Ignore this message.
else
{
OutputDataPort(Microsoft.XLANGs.BaseTypes.Address) =
"FILE://C:/BiztalkProjects/DynamicFilePorts/" +
IncomingMessage.Destination +
"/IgnoreMessage_%MessageID%.xml";
}
Step 7: Create two Ports (a Receive port and a Send port)
Name as "InputDataPort", leave all the default properties as it is in the Wizard.
Name as "OutputDataPort", set the remaining properties as shown in the image below... Step 8: Strong name and deployment!!
In the BizTalk Explorer, right-click on the listed Orchestration under the "Orchestration" folder, and select "Start". The Orchestration icon must turn blue.
Step 9: Refresh BizTalk Explorer and create Receive Location.
Step 10: Test the Solution
Activate property to "True" for the first Receive Shape in the orchestration.
if-else conditions used directly in the "Expression" shape, instead of using a "Decide" shape.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 1 Mar 2006 Editor: Chris Maunder |
Copyright 2006 by Naveen Karamchetti Everything else Copyright © CodeProject, 1999-2009 Web19 | Advertise on the Code Project |