We have an incoming message that contains an item list and a source system attached to every item. We need to split this incoming message based upon source and send it to appropriate locations.
First, we create an input schema. This schema contains a repeating Item node and Source field. We make the Source field at root level promoted. We will later use this promoted field for routing.
We create another schema that will hold the unique source system value. We will extract the unique source systems from the input message.
Create a SourceSystems schema and import the Source schema into this.
Now we have completed our schemas. The next step is to create maps for our solution. Our first map will extract the unique source systems from the input message into the SourceSystems message.
In this map we used a simple code to get unique source systems.
Out next map is to get all items that belongs to any specific source. This map will have two source schemas and a destination schema. The first schema will be the input message and the second schema will contain a single source system.
BizTalk mapper does not support multiple source schema so, we will use a simple trick to create such map. Instead of creating a map in BizTalk mapper we create map in a transform shape. This allows us to select multiple Source and Destination messages.
In Source, select Input message and Single Source Message.
In Destination, select Output message. Make sure to check “When I Click OK, launch the Biztalk Mapper” before clicking OK. This will open the mapper where you can do the actual mapping.
Use Equal functoid and provide the Source field from the Input message and the Value from the Source message. This logic will filter the items based upon the source system provided.
Our schemas and maps are completed now. The next step is to put them altogether into an orchestration. Here is the process flow in the orchestration.
- Receive Input message.
- Transform Input message into Source Systems message.
- Loop through each source system.
- In the loop extract a single source system, this will act as a filter while we are splitting the input message.
- Transform Input message to output message for a single source system.
- Send the split message to the send port.
At this point, we have split out input message into multiple output messages based upon source system. The next part of our problem is to send these message to different locations based upon the same source system.
Remember, we promoted the Source field while we created Input schema. We will use this property to route our messages. For this purpose, we will publish our messages directly to message box and create a subscription with send ports. We will select Direct port binding while creating a send port in our orchestration.
Create a send port for any single location and subscribe with the message using a filter expression.