Problem

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.

Solution

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.

Blog-7-31-15-01

We create another schema that will hold the unique source system value. We will extract the unique source systems from the input message.

Blog-7-31-15-02

Create a SourceSystems schema and import the Source schema into this.

Blog-7-31-15-03

 

Blog-7-31-15-04

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.

Blog-7-31-15-05

In this map we used a simple code to get unique source systems.

Blog-7-31-15-06

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.

Blog-7-31-15-07

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.

Blog-7-31-15-08

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.

Blog-7-31-15-09

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.

  1. Receive Input message.
  2. Transform Input message into Source Systems message.
  3. Loop through each source system.
  4. In the loop extract a single source system, this will act as a filter while we are splitting the input message.
  5. Transform Input message to output message for a single source system.
  6. Send the split message to the send port.

Blog-7-31-15-10

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.

Blog-7-31-15-11

Create a send port for any single location and subscribe with the message using a filter expression.

Blog-7-31-15-12

Blog-7-31-15-13