Stacking Maps in BizTalk Server
Scenario: I have a need to process two transformations back-to-back. For example, I have Schema1, Schema2, and Schema3, and I have two maps:
- Schema1 -> Schema2
- Schema2 -> Schema3
Schema1 is our canonical schema, meaning this is the schema we always use to "publish" to the MessageBox database. Consider this diagram in which we receive a message and publish the update to two line-of-business (LOB) applications:
Notice what's missing? There is no Schema1 -> Schema3 map.
In the real-life scenario that inspired this test, the maps are very complicated and it would be too much of an undertaking (currently) to invent a new map for transforming Schema1 directly to Schema3. So how do we apply multiple maps in a row using BizTalk?
For this example, I've built out three schemas and two maps, as outlined above. Here are the schemas:
Complicated, I know! =)
First, the easy approach: Orchestration.
This works, however the message in the real-life scenario is over 600MB. BizTalk Server, by default, will swap to disk for transforms performed in an orchestration when the message is over 1MB in size (see the note about TransformThreshold in this article). We can increase this threshold if needed, but 600MB is a bit excessive, I think.
Once orchestration was ruled out, my first thought was to do something in a pipeline component; however, I wanted to see if I could do this without code.
So how about this: I set up a WCF-based NetTCP receive location (and BizTalk sets up its own service host -- how nice) and a corresponding NetTCP send port. (In retrospect NetNamedPipes might have been better? Not sure, but this still worked.) On the way out of the send port, we transform to Schema2, which is published back to the MessageBox by the receive port. Finally, our LOB2 send port applies the second map on its way out.
Yeah, yeah... it's clumsy... it's kind of a hack... but it was fun.
Seriously, however, if anyone has a different approach, I'm all ears. =) Eventually the "correct" solution will be to create a map which transforms Schema1 directly to Schema3.
Technorati Tags: BizTalk