Search code examples
biztalkpipelinebiztalk-2010

How to pick XSD in pipeline dynamically during runtime?


I have a requirement where in i am receiving position based data in txt format.

First 2 characters of the record helps me identify the message type.

No i have 40+ message type so based on the message type i need to pick up an xsd in the receive pipeline.

What would be the best way to pick up an xsd in an pipeline dynamically during runtime?


Solution

  • Short Answer

    What you are after, is creating a custom flat file disassembler component, that hosts an instance of the builtin flat file component, but which also implements the IProbeMessage interface.

    This interface allows the BizTalk runtime to select between several components in the Disassemble stage of a Receive Pipeline.

    You could get away with using several versions of this custom pipeline, one for each of the available flat file .XSD schema,

    Unfortunately, this solution would quickly become a maintenance nightmare and a performance problem. Therefore, I would recommend to go one step further, and build a single such component that dynamically selects the flat file schema to use.

    For this, you need to build a plug-in system to drive the IProbeMessage implementation. Each instance of your plug'in would be configured to return the correct flat file .XSD schema and check in the input stream of the received message whether the format matches (probably based upon the first few starting bytes). Your custom pipeline component would then delegate its IProbeMessage implementation to the various plug'ins, in turn, until the message is recognized and the flat file .XSD schema is returned.

    Long Answer

    I could reproduce a long answer here, but please, take a look at the following series of articles I wrote on my blog. These posts walk you through the implementation of a custom flat file disassembler component that dynamically resolves which flat file .XSD schema to use at runtime, using the exact technique I just described above.

    Please, start here: